Skip to content

Commit a04b577

Browse files
Hayden Braxtonmanucorporat
Hayden Braxton
authored andcommittedMay 1, 2017
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
1 parent 2afc5cf commit a04b577

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
 

‎src/components/select/select.ts

+16
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ export class Select extends BaseInput<any> implements OnDestroy {
151151

152152
_multi: boolean = false;
153153
_options: QueryList<Option>;
154+
_overlay: ActionSheet | Alert | Popover;
154155
_texts: string[] = [];
155156
_text: string = '';
156157

@@ -364,16 +365,31 @@ export class Select extends BaseInput<any> implements OnDestroy {
364365
overlay.present(selectOptions);
365366

366367
this._fireFocus();
368+
367369
overlay.onDidDismiss((value: any) => {
368370
this._fireBlur();
369371

370372
if (this.interface === 'popover' && value) {
371373
this.value = value;
372374
this.ionChange.emit(value);
373375
}
376+
377+
this._overlay = undefined;
374378
});
379+
380+
this._overlay = overlay;
375381
}
376382

383+
/**
384+
* Close the select interface.
385+
*/
386+
close() {
387+
if (!this._overlay || !this.isFocus()) {
388+
return;
389+
}
390+
391+
return this._overlay.dismiss();
392+
}
377393

378394
/**
379395
* @input {boolean} If true, the element can accept multiple values.

0 commit comments

Comments
 (0)
Please sign in to comment.