-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(autocomplete): add opened/closed events to panel #9904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Adds the `opened` and `closed` event emitters to the autocomplete panel, allowing consumers to react to the panel being opened and closed. Fixes angular#9894.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -181,6 +181,7 @@ export class MatAutocompleteTrigger implements ControlValueAccessor, OnDestroy { | |||
|
|||
if (this._panelOpen) { | |||
this.autocomplete._isOpen = this._panelOpen = false; | |||
this.autocomplete.closed.emit(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to emit the selected value if it's being closed as a result of a selection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to pick that one up from the optionSelected
event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was kind of thinking of a way to implement (simplify my implementation of) the force selection. So if the closed emitted a null
, I'd know that no option would have been selected. Without it, I think I'll have to combine closed
with panelClosingActions
. Something like (if panelClosingActions
emits before closed
):
this.trigger.autocomplete.closed
.pipe(
withLatestFrom(this.trigger.panelClosingActions)
)
If the order of the events is inverted, I'll have to combine them in another way (maybe window
operator?).
This dependency on the order of the emissions is not very comfortable.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Adds the
opened
andclosed
event emitters to the autocomplete panel, allowing consumers to react to the panel being opened and closed.Fixes #9894.