Skip to content

Commit

Permalink
fix(datepicker): prevent auto open of datepicker slave
Browse files Browse the repository at this point in the history
The datepicker slave automatically opens its toggle on multiple triggers.
For some circumstances this is annoying for the user. This change allows
to configure the slave via an input to prevent this behaviour.

closes sbb-design-systems#36
  • Loading branch information
daniel-sc committed Jun 17, 2019
1 parent 36745d0 commit abe4d59
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ export class DatepickerComponent<D> implements OnDestroy {

master: DatepickerComponent<D> | null;

/**
* If set to <code>true</code> (default: <code>false</code>) on a slave instance,
* it will not open the date picker automatically
*/
@Input() preventAutoOpen = false;

@HostBinding('class.sbb-datepicker') cssClass = true;

/**
Expand Down Expand Up @@ -327,7 +333,8 @@ export class DatepickerComponent<D> implements OnDestroy {
v => !!this.slave.selected && this._dateAdapter.compareDate(v, this.slave.selected) > 0
),
tap(r => (r ? (this.slave.datepickerInput.value = null) : undefined)),
filter(() => !this.slave.datepickerInput.value)
filter(() => !this.slave.datepickerInput.value),
filter(() => !this.preventAutoOpen)
)
.subscribe(() => this.slave.open());
}
Expand Down

0 comments on commit abe4d59

Please sign in to comment.