mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
feat(select): close select programatically
* implement ability to close select programmatically * refactor(select): made changes based on PR feedback, namely assigning overlay to the overlay property at then end of the open function, applying DeMorgan's Law to a condition, and returning the overlay dismiss promise from the close function * refactor(select): made additional changes to closing select component programmatically to resolve issue 11318
This commit is contained in:
@ -151,6 +151,7 @@ export class Select extends BaseInput<any> implements OnDestroy {
|
||||
|
||||
_multi: boolean = false;
|
||||
_options: QueryList<Option>;
|
||||
_overlay: ActionSheet | Alert | Popover;
|
||||
_texts: string[] = [];
|
||||
_text: string = '';
|
||||
|
||||
@ -364,6 +365,7 @@ export class Select extends BaseInput<any> implements OnDestroy {
|
||||
overlay.present(selectOptions);
|
||||
|
||||
this._fireFocus();
|
||||
|
||||
overlay.onDidDismiss((value: any) => {
|
||||
this._fireBlur();
|
||||
|
||||
@ -371,9 +373,23 @@ export class Select extends BaseInput<any> implements OnDestroy {
|
||||
this.value = value;
|
||||
this.ionChange.emit(value);
|
||||
}
|
||||
|
||||
this._overlay = undefined;
|
||||
});
|
||||
|
||||
this._overlay = overlay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the select interface.
|
||||
*/
|
||||
close() {
|
||||
if (!this._overlay || !this.isFocus()) {
|
||||
return;
|
||||
}
|
||||
|
||||
return this._overlay.dismiss();
|
||||
}
|
||||
|
||||
/**
|
||||
* @input {boolean} If true, the element can accept multiple values.
|
||||
|
Reference in New Issue
Block a user