Skip to content

Focus is lost when opening md-select options list #6690

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
rubenlagus opened this issue Aug 29, 2017 · 6 comments · Fixed by #6856
Closed

Focus is lost when opening md-select options list #6690

rubenlagus opened this issue Aug 29, 2017 · 6 comments · Fixed by #6856
Assignees

Comments

@rubenlagus
Copy link

Bug, feature request, or proposal:

When an user opens the md-select options list, focus is lost from the component itself.

What is the expected behavior?

Focus should remain in a child of md-select options and events such as focusin or focusout should not be triggered since the user has not really leave the component at tall.

What is the current behavior?

As soon as the options list opens, focus is lost form the component containing the md-select.

What are the steps to reproduce?

Check focus log when selecting options: http://plnkr.co/uySEJGxzMTkbO6DxlT1F

What is the use-case or motivation for changing an existing behavior?

In order to be able to track focus events and being able to apply custom styles to a component when it is focused, it is necessary that those events allow to track when the user really leave the component and they don't trigger while the user is selecting an option inside a form (for example).

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Tested with Angular 4.3.1, Material 2.0.0-beta.8 under Chrome.

@rubenlagus
Copy link
Author

Update:
It is still happening with latest beta 2.0.0-beta.10 and Angular 4.3.6

@willshowell
Copy link
Contributor

Focus moves to the select options which, in the DOM, are in an overlay at the end of the body. What if the select component had a class like mat-select-open when the panel was open?

@rubenlagus
Copy link
Author

rubenlagus commented Sep 4, 2017

@willshowell in my use case, I'm using a directive that use focusin and focusout events to add/remove styles to the whole component. I could add a workaround to those event that also check if the mat-select-open is present.

I would prefer to get those event only when the actual focus is indeed moved away from the component (and yes, I know that internally in the DOM it is like that).

What about trying to avoid the event to bubble out of the md-select?

P.S: I can provide the Directive code in case it is needed.

@willshowell
Copy link
Contributor

I see, cc @crisbeto

@crisbeto
Copy link
Member

crisbeto commented Sep 5, 2017

I'm currently working on switching md-select to use aria-activedescendant instead of moving focus. This shouldn't be an issue once it is in place.

@crisbeto crisbeto self-assigned this Sep 5, 2017
@crisbeto crisbeto added the has pr label Sep 5, 2017
crisbeto added a commit to crisbeto/material2 that referenced this issue Sep 5, 2017
* Refactors the select to use `aria-activedescendant` to announce the highlighted item to screen readers. Previously we would this through focus, however using focus prevents us from being able to do things like angular#3211.
* Fixes a hack that was used to get a hold of the panel element using `querySelector`. Now it properly uses a `ViewChild` query, however this meant some tests had to be updated.

Relates to angular#3211.
Fixes angular#6690.
crisbeto added a commit to crisbeto/material2 that referenced this issue Sep 6, 2017
* Refactors the select to use `aria-activedescendant` to announce the highlighted item to screen readers. Previously we would this through focus, however using focus prevents us from being able to do things like angular#3211.
* Fixes a hack that was used to get a hold of the panel element using `querySelector`. Now it properly uses a `ViewChild` query, however this meant some tests had to be updated.

Relates to angular#3211.
Fixes angular#6690.
crisbeto added a commit to crisbeto/material2 that referenced this issue Sep 13, 2017
* Refactors the select to use `aria-activedescendant` to announce the highlighted item to screen readers. Previously we would this through focus, however using focus prevents us from being able to do things like angular#3211.
* Fixes a hack that was used to get a hold of the panel element using `querySelector`. Now it properly uses a `ViewChild` query, however this meant some tests had to be updated.

Relates to angular#3211.
Fixes angular#6690.
crisbeto added a commit to crisbeto/material2 that referenced this issue Sep 19, 2017
* Refactors the select to use `aria-activedescendant` to announce the highlighted item to screen readers. Previously we would this through focus, however using focus prevents us from being able to do things like angular#3211.
* Fixes a hack that was used to get a hold of the panel element using `querySelector`. Now it properly uses a `ViewChild` query, however this meant some tests had to be updated.

Relates to angular#3211.
Fixes angular#6690.
crisbeto added a commit to crisbeto/material2 that referenced this issue Sep 23, 2017
* Refactors the select to use `aria-activedescendant` to announce the highlighted item to screen readers. Previously we would this through focus, however using focus prevents us from being able to do things like angular#3211.
* Fixes a hack that was used to get a hold of the panel element using `querySelector`. Now it properly uses a `ViewChild` query, however this meant some tests had to be updated.

Relates to angular#3211.
Fixes angular#6690.
crisbeto added a commit to crisbeto/material2 that referenced this issue Sep 29, 2017
* Refactors the select to use `aria-activedescendant` to announce the highlighted item to screen readers. Previously we would this through focus, however using focus prevents us from being able to do things like angular#3211.
* Fixes a hack that was used to get a hold of the panel element using `querySelector`. Now it properly uses a `ViewChild` query, however this meant some tests had to be updated.

Relates to angular#3211.
Fixes angular#6690.
crisbeto added a commit to crisbeto/material2 that referenced this issue Sep 30, 2017
* Refactors the select to use `aria-activedescendant` to announce the highlighted item to screen readers. Previously we would this through focus, however using focus prevents us from being able to do things like angular#3211.
* Fixes a hack that was used to get a hold of the panel element using `querySelector`. Now it properly uses a `ViewChild` query, however this meant some tests had to be updated.

Relates to angular#3211.
Fixes angular#6690.
@kara kara closed this as completed in #6856 Oct 3, 2017
kara pushed a commit that referenced this issue Oct 3, 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
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants