-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
fix(autocomplete): emit closing action for escape keydown event #6250
Conversation
549b86c
to
133b03f
Compare
8d5b0b6
to
6d8da62
Compare
6d8da62
to
47088f6
Compare
@kara @crisbeto would one of you mind reviewing this? It's really simple and a big help for #3334 (comment). |
@@ -275,7 +280,7 @@ export class MdAutocompleteTrigger implements ControlValueAccessor, OnDestroy { | |||
_handleKeydown(event: KeyboardEvent): void { | |||
if (event.keyCode === ESCAPE && this.panelOpen) { | |||
this._resetActiveItem(); | |||
this.closePanel(); | |||
this._escapeEventStream.next(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.
Since it only fires for escape presses, I don't think it's necessary to pass along the event.
@@ -130,6 +131,9 @@ export class MdAutocompleteTrigger implements ControlValueAccessor, OnDestroy { | |||
/** The subscription for closing actions (some are bound to document). */ | |||
private _closingActionsSubscription: Subscription; | |||
|
|||
/** Stream of escape keyboard events. */ | |||
private _escapeEventStream = new Subject<KeyboardEvent>(); |
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.
Can you also complete this in ngOnDestroy
?
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
e134ecc
to
c6cd992
Compare
c6cd992
to
b61af4f
Compare
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. |
Fixes #6209
This also adds tests for the existing
panelClosingActions