Skip to content

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

Merged
merged 1 commit into from
Feb 13, 2018

Conversation

crisbeto
Copy link
Member

Adds the opened and closed event emitters to the autocomplete panel, allowing consumers to react to the panel being opened and closed.

Fixes #9894.

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.
@crisbeto crisbeto requested a review from kara as a code owner February 12, 2018 19:37
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Feb 12, 2018
@jelbourn jelbourn added the target: major This PR is targeted for the next major release label Feb 12, 2018
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Feb 12, 2018
@jelbourn jelbourn merged commit 82c5ff0 into angular:master Feb 13, 2018
@@ -181,6 +181,7 @@ export class MatAutocompleteTrigger implements ControlValueAccessor, OnDestroy {

if (this._panelOpen) {
this.autocomplete._isOpen = this._panelOpen = false;
this.autocomplete.closed.emit();
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

@julianobrasil julianobrasil Feb 25, 2018

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.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autocomplete - Add a panelOpened event
4 participants