Skip to content

Commit 3ca2928

Browse files
authored
Merge pull request #4381 from IgniteUI/SAndreeva/time-picker-overlay-settings
Expose time picker overlay settings as an @input()
2 parents c94affa + e0217a6 commit 3ca2928

File tree

1 file changed

+39
-18
lines changed

1 file changed

+39
-18
lines changed

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

+39-18
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import { Subject, fromEvent, interval, animationFrameScheduler } from 'rxjs';
3535
import { EditorProvider } from '../core/edit-provider';
3636
import { IgxTimePickerBase, IGX_TIME_PICKER_COMPONENT } from './time-picker.common';
3737
import { IgxOverlayService } from '../services/overlay/overlay';
38-
import { NoOpScrollStrategy } from '../services/overlay/scroll';
38+
import { AbsoluteScrollStrategy } from '../services/overlay/scroll';
3939
import { ConnectedPositioningStrategy } from '../services/overlay/position';
4040
import { HorizontalAlignment, VerticalAlignment, PositionSettings, OverlaySettings } from '../services/overlay/utilities';
4141
import { takeUntil, filter, throttle } from 'rxjs/operators';
@@ -338,6 +338,23 @@ export class IgxTimePickerComponent implements
338338
@Input()
339339
public outlet: IgxOverlayOutletDirective | ElementRef;
340340

341+
/**
342+
* An @Input property that allows you to modify overlay positioning, interaction and scroll behavior.
343+
* ```typescript
344+
* const settings: OverlaySettings = {
345+
* closeOnOutsideClick: true,
346+
* modal: false
347+
* }
348+
* ```
349+
* ---
350+
* ```html
351+
* <igx-time-picker [overlaySettings]="settings"></igx-time-picker>
352+
* ```
353+
* @memberof IgxTimePickerComponent
354+
*/
355+
@Input()
356+
public overlaySettings: OverlaySettings;
357+
341358
/**
342359
* Emitted when selection is made. The event contains the selected value. Returns {`oldValue`: `Date`, `newValue`: `Date`}.
343360
*```typescript
@@ -704,7 +721,7 @@ export class IgxTimePickerComponent implements
704721
this._dropDownOverlaySettings = {
705722
modal: false,
706723
closeOnOutsideClick: true,
707-
scrollStrategy: new NoOpScrollStrategy(),
724+
scrollStrategy: new AbsoluteScrollStrategy(),
708725
positionStrategy: new ConnectedPositioningStrategy(this._positionSettings)
709726
};
710727

@@ -1143,27 +1160,31 @@ export class IgxTimePickerComponent implements
11431160
* ```
11441161
*/
11451162
public openDialog(timePicker: IgxTimePickerComponent = this): void {
1146-
if (this.mode === InteractionMode.Dialog) {
1163+
1164+
if (this.collapsed) {
11471165
this.collapsed = false;
1148-
if (this.outlet) {
1149-
this._dialogOverlaySettings.outlet = this.outlet;
1166+
1167+
let settings;
1168+
if (this.mode === InteractionMode.Dialog) {
1169+
settings = this.overlaySettings || this._dialogOverlaySettings;
11501170
}
1151-
this._overlayId = this.overlayService.attach(this.container, this._dialogOverlaySettings);
1152-
this.overlayService.show(this._overlayId);
1153-
}
11541171

1155-
if (this.mode === InteractionMode.DropDown) {
1156-
if (this.collapsed) {
1157-
this.collapsed = false;
1158-
if (this.outlet) {
1159-
this._dropDownOverlaySettings.outlet = this.outlet;
1172+
if (this.mode === InteractionMode.DropDown) {
1173+
settings = this.overlaySettings || this._dropDownOverlaySettings;
1174+
if (settings.positionStrategy && settings.positionStrategy.settings) {
1175+
settings.positionStrategy.settings.target = this.group.element.nativeElement;
11601176
}
1161-
this._dropDownOverlaySettings.positionStrategy.settings.target = this.group.element.nativeElement;
1162-
this._overlayId = this.overlayService.attach(this.container, this._dropDownOverlaySettings);
1163-
this.overlayService.show(this._overlayId);
1164-
} else {
1165-
this._onDropDownClosed();
11661177
}
1178+
1179+
if (this.outlet) {
1180+
settings.outlet = this.outlet;
1181+
}
1182+
1183+
this._overlayId = this.overlayService.attach(this.container, settings);
1184+
this.overlayService.show(this._overlayId);
1185+
1186+
} else if (this.mode === InteractionMode.DropDown) {
1187+
this._onDropDownClosed();
11671188
}
11681189

11691190
if (this.value) {

0 commit comments

Comments
 (0)