-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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): handle escape key #4703
Conversation
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. Thanks for updating the keyboard event function!
@@ -231,7 +231,9 @@ export class MdAutocompleteTrigger implements ControlValueAccessor, OnDestroy { | |||
} | |||
|
|||
_handleKeydown(event: KeyboardEvent): void { | |||
if (this.activeOption && event.keyCode === ENTER) { | |||
if (event.keyCode === ESCAPE) { | |||
this.panelOpen ? this.closePanel() : this._element.nativeElement.blur(); |
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.
Where does this blur
put the focus? If it dumps it back to the body
, then we don't want this behavior
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.
I tested that manually, and it seems to go to the next in the tab order on TAB. But the active element is the body. Thoughts?
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.
@crisbeto Discussed a bit, and seems like a noop might be a better choice if the panel is closed given screenreader support.
a84b4e0
to
4681e43
Compare
Removed the |
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
4681e43
to
e100f6e
Compare
* Closes the autocomplete panel when pressing escape. * Switches the autocomplete unit tests to using the common utility for creating fake keyboard events.
e100f6e
to
e08ca2d
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. |
fix(autocomplete): handle escape key