Skip to content

mat-select should close when escape is pressed, also stop propagation #7981

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
alex-okrushko opened this issue Oct 23, 2017 · 7 comments
Closed
Assignees
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@alex-okrushko
Copy link
Contributor

Bug, feature request, or proposal:

bug?

What is the expected behavior?

when mat-select is open and escape is pressed it should close the select

What is the current behavior?

select doesn't close and the element upstream gets the escape. In my case the mat-drawer catches this Escape which results in weird behavior: drawer closes, and the opened select is floating outside of it (because it's part of the cdk-portal).

What are the steps to reproduce?

http://plnkr.co/edit/vtBv4N8p0o4hzFetaOGx?p=preview

Open drawer
Click the selector
Press ESC

@crisbeto crisbeto self-assigned this Oct 23, 2017
@alex-okrushko
Copy link
Contributor Author

e14626e2-0697-44bc-bae1-8014b157f927

crisbeto added a commit to crisbeto/material2 that referenced this issue Oct 26, 2017
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
Copy link
Member

Closing as something that will be resolved by #8531.

@alex-okrushko
Copy link
Contributor Author

This wasn't fixed
here is with the latest material and angular 5.2.1 http://plnkr.co/edit/aJTfUQ5O8L6SN0t4fLrm?p=preview

@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed has pr labels Jan 23, 2018
@crisbeto crisbeto reopened this Jan 23, 2018
@genyklemberg
Copy link

genyklemberg commented Feb 6, 2018

this is because of class="cdk-overlay-backdrop" You should change proper z-index

@alex-okrushko
Copy link
Contributor Author

Not reproducible any more

@stagefright5
Copy link

stagefright5 commented Jul 11, 2019

@alex-okrushko , It is still easily reproducible. Please look at this example:
https://stackblitz.com/edit/angular-awab22?file=app%2Fsidenav-autosize-example.html

@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 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants