Skip to content
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

Merged
merged 1 commit into from May 26, 2017

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented May 21, 2017

fix(autocomplete): handle escape key

  • Closes the autocomplete panel when pressing escape.
  • Switches the autocomplete unit tests to using the common utility for creating fake keyboard events.

@crisbeto crisbeto added Accessibility This issue is related to accessibility (a11y) pr: needs review labels May 21, 2017
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label May 21, 2017
Copy link
Contributor

@kara kara left a 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!

@kara kara removed their assignment May 22, 2017
@kara kara added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels May 22, 2017
@@ -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();
Copy link
Member

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

Copy link
Contributor

@kara kara May 22, 2017

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?

Copy link
Contributor

@kara kara May 22, 2017

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.

@jelbourn jelbourn removed the action: merge The PR is ready for merge by the caretaker label May 22, 2017
@crisbeto
Copy link
Member Author

Removed the blur @kara.

Copy link
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

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

LGTM

@kara kara removed their assignment May 22, 2017
@kara kara added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels May 22, 2017
* Closes the autocomplete panel when pressing escape.
* Switches the autocomplete unit tests to using the common utility for creating fake keyboard events.
@tinayuangao tinayuangao merged commit 9e2a66c into angular:master May 26, 2017
@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 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Accessibility This issue is related to accessibility (a11y) action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants