Skip to content

Commit af61717

Browse files
authored
Merge pull request #5091 from IgniteUI/vbogomolov/timepicker-outlet
Outlet prop for timepicker dialog mode working correctly
2 parents 04cbe4c + f4afc08 commit af61717

File tree

2 files changed

+41
-4
lines changed

2 files changed

+41
-4
lines changed

projects/igniteui-angular/src/lib/time-picker/time-picker.component.spec.ts

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { IgxInputGroupModule } from '../input-group';
1010
import { configureTestSuite } from '../test-utils/configure-suite';
1111
import { InteractionMode } from '../core/enums';
1212
import { IgxIconModule } from '../icon';
13+
import { IgxOverlayOutletDirective, IgxToggleModule } from '../directives/toggle/toggle.directive';
1314

1415
describe('IgxTimePicker', () => {
1516
configureTestSuite();
@@ -28,14 +29,16 @@ describe('IgxTimePicker', () => {
2829
IgxTimePickerDropDownComponent,
2930
IgxTimePickerDropDownSingleHourComponent,
3031
IgxTimePickerDropDownNoValueComponent,
31-
IgxTimePickerRetemplatedDropDownComponent
32+
IgxTimePickerRetemplatedDropDownComponent,
33+
IgxTimePickerWithOutletComponent
3234
],
3335
imports: [
3436
IgxTimePickerModule,
3537
FormsModule,
3638
NoopAnimationsModule,
3739
IgxInputGroupModule,
38-
IgxIconModule
40+
IgxIconModule,
41+
IgxToggleModule
3942
]
4043
}).compileComponents();
4144
}));
@@ -1472,6 +1475,29 @@ describe('IgxTimePicker', () => {
14721475

14731476
expect(document.getElementsByClassName('igx-time-picker__buttons').length).toEqual(0);
14741477
}));
1478+
1479+
});
1480+
1481+
describe('Timepicker with outlet', () => {
1482+
configureTestSuite();
1483+
let fixture;
1484+
let timePicker;
1485+
1486+
it('should display the overlay in the provided outlet', fakeAsync(() => {
1487+
fixture = TestBed.createComponent(IgxTimePickerWithOutletComponent);
1488+
timePicker = fixture.componentInstance.timepicker;
1489+
fixture.detectChanges();
1490+
const dom = fixture.debugElement;
1491+
1492+
expect(() => {
1493+
const timePickerTarget = dom.query(By.directive(IgxInputDirective));
1494+
UIInteractions.clickElement(timePickerTarget);
1495+
tick();
1496+
fixture.detectChanges();
1497+
}).not.toThrowError();
1498+
1499+
expect(timePicker.outlet).toBeDefined();
1500+
}));
14751501
});
14761502

14771503
describe('TimePicker retemplating and customization', () => {
@@ -1959,6 +1985,16 @@ export class IgxTimePickerRetemplatedDropDownComponent {
19591985
}
19601986
}
19611987

1988+
@Component({
1989+
template: `
1990+
<igx-time-picker [outlet]="outlet" #timepicker></igx-time-picker>
1991+
<div igxOverlayOutlet #outlet="overlay-outlet"></div>
1992+
`
1993+
})
1994+
export class IgxTimePickerWithOutletComponent {
1995+
@ViewChild('timepicker', { static: true }) public timepicker: IgxTimePickerComponent;
1996+
}
1997+
19621998
// helper functions
19631999
function findByInnerText(collection, searchText) {
19642000
for (const element of collection) {

projects/igniteui-angular/src/lib/time-picker/time-picker.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ export class IgxTimePickerComponent implements
371371

372372
public get overlaySettings(): OverlaySettings {
373373
return this._overlaySettings ? this._overlaySettings :
374-
(this.mode === InteractionMode.Dialog ? undefined : this._dropDownOverlaySettings);
374+
(this.mode === InteractionMode.Dialog ? this._dialogOverlaySettings : this._dropDownOverlaySettings);
375375
}
376376

377377
/**
@@ -587,6 +587,7 @@ export class IgxTimePickerComponent implements
587587
private _dateFromModel: Date;
588588
private _destroy$ = new Subject<boolean>();
589589
private _dropDownOverlaySettings: OverlaySettings;
590+
private _dialogOverlaySettings: OverlaySettings;
590591

591592
private _prevSelectedHour: string;
592593
private _prevSelectedMinute: string;
@@ -753,6 +754,7 @@ export class IgxTimePickerComponent implements
753754
scrollStrategy: new AbsoluteScrollStrategy(),
754755
positionStrategy: new AutoPositionStrategy()
755756
};
757+
this._dialogOverlaySettings = {};
756758
}
757759

758760
/**
@@ -1344,7 +1346,6 @@ export class IgxTimePickerComponent implements
13441346
if (target && settings && settings.positionStrategy) {
13451347
settings.positionStrategy.settings.target = target;
13461348
}
1347-
13481349
if (this.outlet) {
13491350
settings.outlet = this.outlet;
13501351
}

0 commit comments

Comments
 (0)