From df3686106195750ea6bda60234f13d79e5435969 Mon Sep 17 00:00:00 2001 From: Bozhidara Pachilova Date: Mon, 11 Aug 2025 16:30:23 +0300 Subject: [PATCH 01/20] feat(drp): use templates for calendar header parts as DP + test --- .../date-range-picker.component.spec.ts | 69 ++++++++++++++++++- .../date-range-picker.component.ts | 17 ++++- .../src/lib/date-range-picker/public_api.ts | 6 +- 3 files changed, 87 insertions(+), 5 deletions(-) diff --git a/projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.spec.ts b/projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.spec.ts index 01d03dc791d..31cba4024fc 100644 --- a/projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.spec.ts +++ b/projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.spec.ts @@ -15,7 +15,7 @@ import { DateRangeType } from '../core/dates'; import { IgxDateRangePickerComponent, IgxDateRangeEndComponent } from './public_api'; import { AutoPositionStrategy, IgxOverlayService } from '../services/public_api'; import { AnimationMetadata, AnimationOptions } from '@angular/animations'; -import { IgxCalendarComponent, WEEKDAYS } from '../calendar/public_api'; +import { IgxCalendarComponent, IgxCalendarHeaderTemplateDirective, IgxCalendarHeaderTitleTemplateDirective, IgxCalendarSubheaderTemplateDirective, WEEKDAYS } from '../calendar/public_api'; import { Subject } from 'rxjs'; import { AsyncPipe } from '@angular/common'; import { AnimationService } from '../services/animation/animation'; @@ -44,6 +44,9 @@ const CSS_CLASS_OVERLAY_CONTENT = 'igx-overlay__content'; const CSS_CLASS_DATE_RANGE = 'igx-date-range-picker'; const CSS_CLASS_CALENDAR_DATE = 'igx-days-view__date'; const CSS_CLASS_INACTIVE_DATE = 'igx-days-view__date--inactive'; +const CSS_CLASS_CALENDAR_HEADER = '.igx-calendar__header-date'; +const CSS_CLASS_CALENDAR_HEADER_TITLE = '.igx-calendar__header-year'; +const CSS_CLASS_CALENDAR_SUBHEADER = '.igx-calendar-picker__dates'; describe('IgxDateRangePicker', () => { describe('Unit tests: ', () => { @@ -1562,6 +1565,62 @@ describe('IgxDateRangePicker', () => { expect(dateRange.locale).toEqual('en-US'); expect(dateRange.weekStart).toEqual(WEEKDAYS.FRIDAY); })); + + it('Should render calendar with header in dialog mode by default', fakeAsync(() => { + fixture = TestBed.createComponent(DateRangeDefaultComponent); + fixture.detectChanges(); + dateRange = fixture.componentInstance.dateRange; + dateRange.mode = 'dialog'; + dateRange.open(); + tick(); + fixture.detectChanges(); + + expect(dateRange['_calendar'].hasHeader).toBeTrue(); + const calendarHeader = fixture.debugElement.query(By.css(CSS_CLASS_CALENDAR_HEADER)); + expect(calendarHeader).toBeTruthy('Calendar header should be present'); + })); + + describe('Templated Calendar Header', () => { + let dateRangeDebugEl: DebugElement; + beforeEach(fakeAsync(() => { + TestBed.configureTestingModule({ + imports: [DateRangeTemplatesComponent] + }).compileComponents(); + + fixture = TestBed.createComponent(DateRangeTemplatesComponent); + fixture.detectChanges(); + dateRangeDebugEl = fixture.debugElement.queryAll(By.directive(IgxDateRangePickerComponent))[0]; + dateRange = dateRangeDebugEl.componentInstance; + dateRange.mode = 'dialog'; + dateRange.open(); + tick(); + fixture.detectChanges(); + })); + + it('Should use the custom template for header title', fakeAsync(() => { + const headerTitleElement = dateRangeDebugEl.query(By.css(CSS_CLASS_CALENDAR_HEADER_TITLE)); + expect(headerTitleElement).toBeTruthy('Header title element should be present'); + if (headerTitleElement) { + expect(headerTitleElement.nativeElement.textContent.trim()).toBe('Test header title'); + } + })); + + it('Should use the custom template for header', fakeAsync(() => { + const headerElement = dateRangeDebugEl.query(By.css(CSS_CLASS_CALENDAR_HEADER)); + expect(headerElement).toBeTruthy('Header element should be present'); + if (headerElement) { + expect(headerElement.nativeElement.textContent.trim()).toBe('Test header'); + } + })); + + it('Should use the custom template for subheader', fakeAsync(() => { + const headerElement = dateRangeDebugEl.query(By.css(CSS_CLASS_CALENDAR_SUBHEADER)); + expect(headerElement).toBeTruthy('Subheader element should be present'); + if (headerElement) { + expect(headerElement.nativeElement.textContent.trim()).toBe('Test subheader'); + } + })); + }); }); }); }); @@ -1684,6 +1743,9 @@ export class DateRangeCustomComponent extends DateRangeTestComponent { flight_takeoff + Test header + Test header title + Test subheader @@ -1727,7 +1789,10 @@ export class DateRangeCustomComponent extends DateRangeTestComponent { IgxInputDirective, IgxDateTimeEditorDirective, IgxPrefixDirective, - IgxSuffixDirective + IgxSuffixDirective, + IgxCalendarHeaderTemplateDirective, + IgxCalendarHeaderTitleTemplateDirective, + IgxCalendarSubheaderTemplateDirective ] }) export class DateRangeTemplatesComponent extends DateRangeTestComponent { diff --git a/projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.ts b/projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.ts index e6b5edca0ba..f0c66d5bb64 100644 --- a/projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.ts +++ b/projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.ts @@ -13,7 +13,7 @@ import { import { fromEvent, merge, MonoTypeOperatorFunction, noop, Subscription } from 'rxjs'; import { filter, takeUntil } from 'rxjs/operators'; -import { CalendarSelection, IgxCalendarComponent } from '../calendar/public_api'; +import { CalendarSelection, IgxCalendarComponent, IgxCalendarHeaderTemplateDirective, IgxCalendarHeaderTitleTemplateDirective, IgxCalendarSubheaderTemplateDirective } from '../calendar/public_api'; import { DateRangeType } from '../core/dates'; import { DateRangePickerResourceStringsEN, IDateRangePickerResourceStrings } from '../core/i18n/date-range-picker-resources'; import { IBaseCancelableBrowserEventArgs, isDate, parseDate, PlatformUtil } from '../core/utils'; @@ -311,6 +311,16 @@ export class IgxDateRangePickerComponent extends PickerBaseDirective @ContentChild(IgxDateRangeSeparatorDirective, { read: TemplateRef }) public dateSeparatorTemplate: TemplateRef; + + @ContentChild(IgxCalendarHeaderTitleTemplateDirective) + private headerTitleTemplate: IgxCalendarHeaderTitleTemplateDirective; + + @ContentChild(IgxCalendarHeaderTemplateDirective) + private headerTemplate: IgxCalendarHeaderTemplateDirective; + + @ContentChild(IgxCalendarSubheaderTemplateDirective) + private subheaderTemplate: IgxCalendarSubheaderTemplateDirective; + /** @hidden @internal */ public get dateSeparator(): string { if (this._dateSeparator === null) { @@ -1080,13 +1090,16 @@ export class IgxDateRangePickerComponent extends PickerBaseDirective private _initializeCalendarContainer(componentInstance: IgxCalendarContainerComponent) { this._calendar = componentInstance.calendar; - this.calendar.hasHeader = false; + this.calendar.hasHeader = !this.isDropdown; this.calendar.locale = this.locale; this.calendar.selection = CalendarSelection.RANGE; this.calendar.weekStart = this.weekStart; this.calendar.hideOutsideDays = this.hideOutsideDays; this.calendar.monthsViewNumber = this.displayMonthsCount; this.calendar.showWeekNumbers = this.showWeekNumbers; + this._calendar.headerTitleTemplate = this.headerTitleTemplate; + this._calendar.headerTemplate = this.headerTemplate; + this._calendar.subheaderTemplate = this.subheaderTemplate; this.calendar.selected.pipe(takeUntil(this._destroy$)).subscribe((ev: Date[]) => this.handleSelection(ev)); componentInstance.mode = this.mode; diff --git a/projects/igniteui-angular/src/lib/date-range-picker/public_api.ts b/projects/igniteui-angular/src/lib/date-range-picker/public_api.ts index 2b0e4fa2367..f25a96a786a 100644 --- a/projects/igniteui-angular/src/lib/date-range-picker/public_api.ts +++ b/projects/igniteui-angular/src/lib/date-range-picker/public_api.ts @@ -1,3 +1,4 @@ +import { IgxCalendarHeaderTemplateDirective, IgxCalendarHeaderTitleTemplateDirective, IgxCalendarSubheaderTemplateDirective } from '../calendar/calendar.directives'; import { IgxPickerToggleComponent } from '../date-common/picker-icons.common'; import { IgxHintDirective } from '../directives/hint/hint.directive'; import { IgxLabelDirective } from '../directives/label/label.directive'; @@ -19,5 +20,8 @@ export const IGX_DATE_RANGE_PICKER_DIRECTIVES = [ IgxLabelDirective, IgxPrefixDirective, IgxSuffixDirective, - IgxHintDirective + IgxHintDirective, + IgxCalendarHeaderTemplateDirective, + IgxCalendarSubheaderTemplateDirective, + IgxCalendarHeaderTitleTemplateDirective ] as const; From 0fe1c0f4e8883e2aa63c9fafe1cc401bc5c2b4be Mon Sep 17 00:00:00 2001 From: Bozhidara Pachilova Date: Mon, 11 Aug 2025 16:48:07 +0300 Subject: [PATCH 02/20] chore(dp): add calendar header templates to public api dirs array --- projects/igniteui-angular/src/lib/date-picker/public_api.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/projects/igniteui-angular/src/lib/date-picker/public_api.ts b/projects/igniteui-angular/src/lib/date-picker/public_api.ts index ce993452a99..f6d632c3cce 100644 --- a/projects/igniteui-angular/src/lib/date-picker/public_api.ts +++ b/projects/igniteui-angular/src/lib/date-picker/public_api.ts @@ -1,3 +1,4 @@ +import { IgxCalendarHeaderTemplateDirective, IgxCalendarHeaderTitleTemplateDirective, IgxCalendarSubheaderTemplateDirective } from '../calendar/calendar.directives'; import { IgxPickerActionsDirective, IgxPickerClearComponent, IgxPickerToggleComponent } from '../date-common/picker-icons.common'; import { IgxHintDirective } from '../directives/hint/hint.directive'; import { IgxLabelDirective } from '../directives/label/label.directive'; @@ -16,5 +17,8 @@ export const IGX_DATE_PICKER_DIRECTIVES = [ IgxLabelDirective, IgxPrefixDirective, IgxSuffixDirective, - IgxHintDirective + IgxHintDirective, + IgxCalendarHeaderTemplateDirective, + IgxCalendarSubheaderTemplateDirective, + IgxCalendarHeaderTitleTemplateDirective ] as const; From e7553e7d2ecf22bf49954e87dbd79657d9f8a558 Mon Sep 17 00:00:00 2001 From: Bozhidara Pachilova Date: Mon, 11 Aug 2025 17:06:48 +0300 Subject: [PATCH 03/20] refactor(picker-base): port headerOrientation prop in base class+test for TP,DRP --- .../lib/date-common/picker-base.directive.ts | 13 ++++++++- .../lib/date-picker/date-picker.component.ts | 13 --------- .../date-range-picker.component.spec.ts | 26 ++++++++++++++++- .../date-range-picker.component.ts | 1 + .../time-picker/time-picker.component.spec.ts | 29 ++++++++++++++++++- .../lib/time-picker/time-picker.component.ts | 13 --------- 6 files changed, 66 insertions(+), 29 deletions(-) diff --git a/projects/igniteui-angular/src/lib/date-common/picker-base.directive.ts b/projects/igniteui-angular/src/lib/date-common/picker-base.directive.ts index e32b343d088..fdd90e1ab3d 100644 --- a/projects/igniteui-angular/src/lib/date-common/picker-base.directive.ts +++ b/projects/igniteui-angular/src/lib/date-common/picker-base.directive.ts @@ -14,7 +14,7 @@ import { IBaseCancelableBrowserEventArgs, IBaseEventArgs } from '../core/utils'; import { IgxOverlayOutletDirective } from '../directives/toggle/toggle.directive'; import { OverlaySettings } from '../services/overlay/utilities'; import { IgxPickerToggleComponent } from './picker-icons.common'; -import { PickerInteractionMode } from './types'; +import { PickerHeaderOrientation, PickerInteractionMode } from './types'; import { WEEKDAYS } from '../calendar/calendar'; import { DateRange } from '../date-range-picker/date-range-picker-inputs.common'; import { IGX_INPUT_GROUP_TYPE, IgxInputGroupType } from '../input-group/inputGroupType'; @@ -78,6 +78,17 @@ export abstract class PickerBaseDirective implements IToggleView, EditorProvider @Input() public mode: PickerInteractionMode = PickerInteractionMode.DropDown; + /** + * Gets/Sets the orientation of the `IgxDatePickerComponent` header. + * + * @example + * ```html + * + * ``` + */ + @Input() + public headerOrientation: PickerHeaderOrientation = PickerHeaderOrientation.Horizontal; + /** * Overlay settings used to display the pop-up element. * diff --git a/projects/igniteui-angular/src/lib/date-picker/date-picker.component.ts b/projects/igniteui-angular/src/lib/date-picker/date-picker.component.ts index a3a6935af7d..3d1f3d1588e 100644 --- a/projects/igniteui-angular/src/lib/date-picker/date-picker.component.ts +++ b/projects/igniteui-angular/src/lib/date-picker/date-picker.component.ts @@ -51,7 +51,6 @@ import { IBaseCancelableBrowserEventArgs, isDate, PlatformUtil } from '../core/u import { IgxCalendarContainerComponent } from '../date-common/calendar-container/calendar-container.component'; import { PickerBaseDirective } from '../date-common/picker-base.directive'; import { IgxPickerActionsDirective, IgxPickerClearComponent } from '../date-common/public_api'; -import { PickerHeaderOrientation } from '../date-common/types'; import { DateTimeUtil } from '../date-common/util/date-time.util'; import { DatePart, DatePartDeltas, IgxDateTimeEditorDirective } from '../directives/date-time-editor/public_api'; import { IgxOverlayOutletDirective } from '../directives/toggle/toggle.directive'; @@ -162,17 +161,6 @@ export class IgxDatePickerComponent extends PickerBaseDirective implements Contr @Input() public formatter: (val: Date) => string; - /** - * Gets/Sets the orientation of the `IgxDatePickerComponent` header. - * - * @example - * ```html - * - * ``` - */ - @Input() - public headerOrientation: PickerHeaderOrientation = PickerHeaderOrientation.Horizontal; - /** * Gets/Sets the today button's label. * @@ -989,7 +977,6 @@ export class IgxDatePickerComponent extends PickerBaseDirective implements Contr this.setCalendarViewDate(); componentInstance.mode = this.mode; - // componentInstance.headerOrientation = this.headerOrientation; componentInstance.closeButtonLabel = this.cancelButtonLabel; componentInstance.todayButtonLabel = this.todayButtonLabel; componentInstance.pickerActions = this.pickerActions; diff --git a/projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.spec.ts b/projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.spec.ts index 31cba4024fc..541cb58bd00 100644 --- a/projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.spec.ts +++ b/projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.spec.ts @@ -1,7 +1,7 @@ import { ComponentFixture, TestBed, fakeAsync, tick, waitForAsync, flush } from '@angular/core/testing'; import { Component, OnInit, ViewChild, DebugElement, ChangeDetectionStrategy } from '@angular/core'; import { IgxInputDirective, IgxInputState, IgxLabelDirective, IgxPrefixDirective, IgxSuffixDirective } from '../input-group/public_api'; -import { PickerInteractionMode } from '../date-common/types'; +import { PickerHeaderOrientation, PickerInteractionMode } from '../date-common/types'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { FormsModule, ReactiveFormsModule, UntypedFormBuilder, UntypedFormControl, Validators } from '@angular/forms'; import { By } from '@angular/platform-browser'; @@ -1580,6 +1580,30 @@ describe('IgxDateRangePicker', () => { expect(calendarHeader).toBeTruthy('Calendar header should be present'); })); + it('should set calendar headerOrientation prop in dialog mode', fakeAsync(() => { + fixture = TestBed.createComponent(DateRangeDefaultComponent); + fixture.detectChanges(); + dateRange = fixture.componentInstance.dateRange; + + dateRange.mode = 'dialog'; + dateRange.open(); + tick(); + fixture.detectChanges(); + + expect(dateRange['_calendar'].headerOrientation).toBe(PickerHeaderOrientation.Horizontal); + + dateRange.close(); + tick(); + fixture.detectChanges(); + + dateRange.headerOrientation = PickerHeaderOrientation.Vertical; + dateRange.open(); + tick(); + fixture.detectChanges(); + + expect(dateRange['_calendar'].headerOrientation).toBe(PickerHeaderOrientation.Vertical); + })); + describe('Templated Calendar Header', () => { let dateRangeDebugEl: DebugElement; beforeEach(fakeAsync(() => { diff --git a/projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.ts b/projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.ts index f0c66d5bb64..e9fb6f12aee 100644 --- a/projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.ts +++ b/projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.ts @@ -1100,6 +1100,7 @@ export class IgxDateRangePickerComponent extends PickerBaseDirective this._calendar.headerTitleTemplate = this.headerTitleTemplate; this._calendar.headerTemplate = this.headerTemplate; this._calendar.subheaderTemplate = this.subheaderTemplate; + this._calendar.headerOrientation = this.headerOrientation; this.calendar.selected.pipe(takeUntil(this._destroy$)).subscribe((ev: Date[]) => this.handleSelection(ev)); componentInstance.mode = this.mode; diff --git a/projects/igniteui-angular/src/lib/time-picker/time-picker.component.spec.ts b/projects/igniteui-angular/src/lib/time-picker/time-picker.component.spec.ts index fa12ed3f60a..4fcb31e7917 100644 --- a/projects/igniteui-angular/src/lib/time-picker/time-picker.component.spec.ts +++ b/projects/igniteui-angular/src/lib/time-picker/time-picker.component.spec.ts @@ -37,6 +37,7 @@ const CSS_CLASS_HEADER_HOUR = '.igx-time-picker__header-hour'; const CSS_CLASS_OVERLAY_WRAPPER = 'igx-overlay__wrapper'; const TIME_PICKER_TOGGLE_ICON = 'access_time'; const TIME_PICKER_CLEAR_ICON = 'clear'; +const CSS_CLASS_TIME_PICKER_VERTICAL = '.igx-time-picker--vertical'; describe('IgxTimePicker', () => { let timePicker: IgxTimePickerComponent; @@ -465,7 +466,7 @@ describe('IgxTimePicker', () => { }); describe('Interaction tests', () => { - let timePickerElement: DebugElement; + let timePickerElement: HTMLElement; let timePickerDebElement: DebugElement; let inputGroup: DebugElement; let hourColumn: DebugElement; @@ -1140,6 +1141,7 @@ describe('IgxTimePicker', () => { fixture = TestBed.createComponent(IgxTimePickerTestComponent); fixture.detectChanges(); timePicker = fixture.componentInstance.timePicker; + timePickerDebElement = fixture.debugElement.query(By.css(CSS_CLASS_TIMEPICKER)); timePickerElement = fixture.debugElement.query(By.css(CSS_CLASS_TIMEPICKER)).nativeElement; inputGroup = fixture.debugElement.query(By.css(`.${CSS_CLASS_INPUTGROUP}`)); hourColumn = fixture.debugElement.query(By.css(`.${CSS_CLASS_HOURLIST}`)); @@ -1570,6 +1572,31 @@ describe('IgxTimePicker', () => { inputEl = fixture.nativeElement.querySelector(CSS_CLASS_INPUT); expect(inputEl.placeholder).toEqual('sample placeholder'); })); + + it('should set headerOrientation prop in dialog mode', fakeAsync(() => { + timePicker.mode = PickerInteractionMode.Dialog; + timePicker.open(); + tick(); + fixture.detectChanges(); + expect(timePicker.headerOrientation).toEqual('horizontal'); + let dialogDivVertical = timePickerDebElement.query(By.css(CSS_CLASS_TIME_PICKER_VERTICAL)); + expect(dialogDivVertical).toBeNull(); + + timePicker.close(); + tick(); + fixture.detectChanges(); + + timePicker.mode = PickerInteractionMode.Dialog; + timePicker.headerOrientation = 'vertical'; + fixture.detectChanges(); + + timePicker.open(); + tick(); + fixture.detectChanges(); + + dialogDivVertical = timePickerDebElement.query(By.css(CSS_CLASS_TIME_PICKER_VERTICAL)); + expect(dialogDivVertical).not.toBeNull(); + })); }); describe('Keyboard navigation', () => { diff --git a/projects/igniteui-angular/src/lib/time-picker/time-picker.component.ts b/projects/igniteui-angular/src/lib/time-picker/time-picker.component.ts index c5174302fec..d70f0bddb6a 100644 --- a/projects/igniteui-angular/src/lib/time-picker/time-picker.component.ts +++ b/projects/igniteui-angular/src/lib/time-picker/time-picker.component.ts @@ -239,19 +239,6 @@ export class IgxTimePickerComponent extends PickerBaseDirective @Input() public formatter: (val: Date) => string; - /** - * Sets the orientation of the picker's header. - * - * @remarks - * Available in dialog mode only. Default value is `horizontal`. - * - * ```html - * - * ``` - */ - @Input() - public headerOrientation: PickerHeaderOrientation = PickerHeaderOrientation.Horizontal; - /** @hidden @internal */ @Input({ transform: booleanAttribute }) public readOnly = false; From 999a9151b1a4b296a7683f22620eeb6af6798f94 Mon Sep 17 00:00:00 2001 From: Bozhidara Pachilova Date: Mon, 11 Aug 2025 17:29:36 +0300 Subject: [PATCH 04/20] feat(picker-base): add hideHeader prop + tests --- .../lib/date-common/picker-base.directive.ts | 11 +++++++++ .../date-picker/date-picker.component.spec.ts | 14 +++++++++++ .../lib/date-picker/date-picker.component.ts | 2 +- .../date-range-picker.component.spec.ts | 23 ++++++++++++++++--- .../date-range-picker.component.ts | 2 +- .../time-picker/time-picker.component.html | 2 +- .../time-picker/time-picker.component.spec.ts | 14 +++++++++++ 7 files changed, 62 insertions(+), 6 deletions(-) diff --git a/projects/igniteui-angular/src/lib/date-common/picker-base.directive.ts b/projects/igniteui-angular/src/lib/date-common/picker-base.directive.ts index fdd90e1ab3d..9d3a4db6214 100644 --- a/projects/igniteui-angular/src/lib/date-common/picker-base.directive.ts +++ b/projects/igniteui-angular/src/lib/date-common/picker-base.directive.ts @@ -89,6 +89,17 @@ export abstract class PickerBaseDirective implements IToggleView, EditorProvider @Input() public headerOrientation: PickerHeaderOrientation = PickerHeaderOrientation.Horizontal; + /** + * Gets/Sets whether the header is hidden in dialog mode. + * + * @example + * ```html + * + * ``` + */ + @Input({ transform: booleanAttribute }) + public hideHeader = false; + /** * Overlay settings used to display the pop-up element. * diff --git a/projects/igniteui-angular/src/lib/date-picker/date-picker.component.spec.ts b/projects/igniteui-angular/src/lib/date-picker/date-picker.component.spec.ts index d208aed8cd2..e9b73b1df9e 100644 --- a/projects/igniteui-angular/src/lib/date-picker/date-picker.component.spec.ts +++ b/projects/igniteui-angular/src/lib/date-picker/date-picker.component.spec.ts @@ -32,6 +32,7 @@ const DATE_PICKER_CLEAR_ICON = 'clear'; const CSS_CLASS_INPUT_GROUP_REQUIRED = 'igx-input-group--required'; const CSS_CLASS_INPUT_GROUP_INVALID = 'igx-input-group--invalid'; +const CSS_CLASS_CALENDAR_HEADER = '.igx-calendar__header'; describe('IgxDatePicker', () => { describe('Integration tests', () => { @@ -66,6 +67,19 @@ describe('IgxDatePicker', () => { expect(suffix).toHaveSize(1); expect(suffix[0].nativeElement.innerText).toEqual(DATE_PICKER_CLEAR_ICON); }); + + it('should hide the calendar header if hideHeader is true in dialog mode', fakeAsync(() => { + const datePicker = fixture.componentInstance.datePicker; + datePicker.mode = 'dialog'; + datePicker.hideHeader = true; + datePicker.open(); + tick(); + fixture.detectChanges(); + + expect(datePicker['_calendar'].hasHeader).toBeFalse(); + const calendarHeader = fixture.debugElement.query(By.css(CSS_CLASS_CALENDAR_HEADER)); + expect(calendarHeader).toBeFalsy('Calendar header should not be present'); + })); }); describe('Events', () => { diff --git a/projects/igniteui-angular/src/lib/date-picker/date-picker.component.ts b/projects/igniteui-angular/src/lib/date-picker/date-picker.component.ts index 3d1f3d1588e..ec948983b26 100644 --- a/projects/igniteui-angular/src/lib/date-picker/date-picker.component.ts +++ b/projects/igniteui-angular/src/lib/date-picker/date-picker.component.ts @@ -954,7 +954,7 @@ export class IgxDatePickerComponent extends PickerBaseDirective implements Contr private _initializeCalendarContainer(componentInstance: IgxCalendarContainerComponent) { this._calendar = componentInstance.calendar; - this._calendar.hasHeader = !this.isDropdown; + this._calendar.hasHeader = !this.isDropdown && !this.hideHeader; this._calendar.formatOptions = this.pickerCalendarFormat; this._calendar.formatViews = this.pickerFormatViews; this._calendar.locale = this.locale; diff --git a/projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.spec.ts b/projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.spec.ts index 541cb58bd00..c86068504f5 100644 --- a/projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.spec.ts +++ b/projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.spec.ts @@ -44,9 +44,10 @@ const CSS_CLASS_OVERLAY_CONTENT = 'igx-overlay__content'; const CSS_CLASS_DATE_RANGE = 'igx-date-range-picker'; const CSS_CLASS_CALENDAR_DATE = 'igx-days-view__date'; const CSS_CLASS_INACTIVE_DATE = 'igx-days-view__date--inactive'; -const CSS_CLASS_CALENDAR_HEADER = '.igx-calendar__header-date'; +const CSS_CLASS_CALENDAR_HEADER_TEMPLATE = '.igx-calendar__header-date'; const CSS_CLASS_CALENDAR_HEADER_TITLE = '.igx-calendar__header-year'; const CSS_CLASS_CALENDAR_SUBHEADER = '.igx-calendar-picker__dates'; +const CSS_CLASS_CALENDAR_HEADER = '.igx-calendar__header'; describe('IgxDateRangePicker', () => { describe('Unit tests: ', () => { @@ -1576,7 +1577,7 @@ describe('IgxDateRangePicker', () => { fixture.detectChanges(); expect(dateRange['_calendar'].hasHeader).toBeTrue(); - const calendarHeader = fixture.debugElement.query(By.css(CSS_CLASS_CALENDAR_HEADER)); + const calendarHeader = fixture.debugElement.query(By.css(CSS_CLASS_CALENDAR_HEADER_TEMPLATE)); expect(calendarHeader).toBeTruthy('Calendar header should be present'); })); @@ -1604,6 +1605,22 @@ describe('IgxDateRangePicker', () => { expect(dateRange['_calendar'].headerOrientation).toBe(PickerHeaderOrientation.Vertical); })); + it('should hide the calendar header if hideHeader is true in dialog mode', fakeAsync(() => { + fixture = TestBed.createComponent(DateRangeDefaultComponent); + fixture.detectChanges(); + dateRange = fixture.componentInstance.dateRange; + + dateRange.mode = 'dialog'; + dateRange.hideHeader = true; + dateRange.open(); + tick(); + fixture.detectChanges(); + + expect(dateRange['_calendar'].hasHeader).toBeFalse(); + const calendarHeader = fixture.debugElement.query(By.css(CSS_CLASS_CALENDAR_HEADER)); + expect(calendarHeader).toBeFalsy('Calendar header should not be present'); + })); + describe('Templated Calendar Header', () => { let dateRangeDebugEl: DebugElement; beforeEach(fakeAsync(() => { @@ -1630,7 +1647,7 @@ describe('IgxDateRangePicker', () => { })); it('Should use the custom template for header', fakeAsync(() => { - const headerElement = dateRangeDebugEl.query(By.css(CSS_CLASS_CALENDAR_HEADER)); + const headerElement = dateRangeDebugEl.query(By.css(CSS_CLASS_CALENDAR_HEADER_TEMPLATE)); expect(headerElement).toBeTruthy('Header element should be present'); if (headerElement) { expect(headerElement.nativeElement.textContent.trim()).toBe('Test header'); diff --git a/projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.ts b/projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.ts index e9fb6f12aee..59aba0e39fa 100644 --- a/projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.ts +++ b/projects/igniteui-angular/src/lib/date-range-picker/date-range-picker.component.ts @@ -1090,7 +1090,7 @@ export class IgxDateRangePickerComponent extends PickerBaseDirective private _initializeCalendarContainer(componentInstance: IgxCalendarContainerComponent) { this._calendar = componentInstance.calendar; - this.calendar.hasHeader = !this.isDropdown; + this._calendar.hasHeader = !this.isDropdown && !this.hideHeader; this.calendar.locale = this.locale; this.calendar.selection = CalendarSelection.RANGE; this.calendar.weekStart = this.weekStart; diff --git a/projects/igniteui-angular/src/lib/time-picker/time-picker.component.html b/projects/igniteui-angular/src/lib/time-picker/time-picker.component.html index 79cd4288ccd..c0358f97a63 100644 --- a/projects/igniteui-angular/src/lib/time-picker/time-picker.component.html +++ b/projects/igniteui-angular/src/lib/time-picker/time-picker.component.html @@ -62,7 +62,7 @@