Skip to content

fix(select): closing parent overlay when pressing escape #8060

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

Closed
wants to merge 1 commit into from

Conversation

crisbeto
Copy link
Member

After the switch to ActiveDescendantKeyManager, the select was no longer handling the escape key functionality internally, but was delegating to the underlying overlay. Since the overlay listens to keyboard events on the document, it means that escape key presses will close any parent overlays along the way. These changes add the escape listener to the select itself and stop the event propagation.

Note: the overlay directive listener should be scoped to the overlay itself, but it's better if we defer refactoring it until #6682 gets in.

Fixes #7981.

After the switch to `ActiveDescendantKeyManager`, the select was no longer handling the escape key functionality internally, but was delegating to the underlying overlay. Since the overlay listens to keyboard events on the document, it means that escape key presses will close any parent overlays along the way. These changes add the escape listener to the select itself and stop the event propagation.

**Note:** the overlay directive listener should be scoped to the overlay itself, but it's better if we defer refactoring it until angular#6682 gets in.

Fixes angular#7981.
@crisbeto crisbeto added Accessibility This issue is related to accessibility (a11y) pr: needs review labels Oct 26, 2017
@crisbeto crisbeto requested a review from kara as a code owner October 26, 2017 21:07
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Oct 26, 2017
@willshowell
Copy link
Contributor

@crisbeto fyi #6682 is merged, in case you want to try your other solution before review

@crisbeto
Copy link
Member Author

Closing in favor of #8531.

@crisbeto crisbeto closed this Nov 19, 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 7, 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) 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.

mat-select should close when escape is pressed, also stop propagation
4 participants