-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Return focus after dialogs close #11999
Conversation
Approvals is slower than usual... something I did? 😕 😄 |
Bram is on Holiday 😄 I haven't been able to take a look yet. |
Ah I was wondering where he disappeared to. Okay thanks for the heads up. |
Any chance this can get a review in time for April's beta? |
I wonder if we need this change, as I think the issue is the location in the DOM where we add the dialogs probably? They are in a different place in the DOM then the element that triggers it... Would have to look in to that |
There's no code in You could make the argument that |
I'm using Chrome on MacOS |
I don't have a Mac to reproduce that, but I'd be shocked if webkit was actively trying to return focus. It doesn't do that on iOS. In any case,leaving it up to the browser isn't a good or even consistent approach as I said, and it's definitely not |
PS - At least on that demo page, Chrome/blink on Windows seems to send focus to the next button rather than the one that opened the dialog, which is not the desired behavior. |
@bramkragten so what's the review verdict here? Have I convinced you this code is needed independent of |
Yeah, I'm seriously considering it, want to make it as easy as possible to maintain... Will get back to you this week. |
@bramkragten I don't understand the maintainability concerns. This is not particularly complicated code. Of course I'm open to review suggestions. @zsarnett can you add your review cents here? |
@balloob can you intercede here? I've commented in the past that HA does not prioritize accessibility and this PR lingering on without a review is an example. This implements simple focus management for dialogs - a fundamental piece of good keyboard accessibility. |
Please stop pinging developers. Bram advised he will be reviewing. This is not about limiting Accessibility so don't try to pull on that string. This is about maintainability. Normally your PRs go through without much question. This one adds a lot of code we have to maintain. Be patient |
That was weeks ago and much work has come and merged since. I don't see any problem with trying to call attention and start a discussion with the project's lead on prioritizing accessibility. It was not meant to offend anyone.
I didn't accuse the project of limiting accessibility. I accused the project of not prioritizing it. There's a huge difference. If there is a way to make it more maintainable, then review and I'd be happy to implement it. No one has done that.
Please don't pretend like this is an exorbitant amount of code. Again, many more lines have come and merged since. And, just as food for thought, do you have any idea how often people with disabilities are told to be patient when trying to resolve accessibility or accommodation issues? It's not about patience - it's just about treating those issues with the priority they deserve. |
The closed targets are now just a set based on a search for the active element and flagged ancestors, and no details of components are needed outside their constructor: - Revert previous changes to deepActiveElement - Add new utility to find flagged ancestors - Flag certain components as safe focus targets - Await next paint instead of just underlay dialog to be more robust
@bramkragten this is ready for another look. I like this version better and I think it settles all your issues. |
Looks a lot better 👍 |
Proposed change
Adds an event handler to return focus, where possible, to the button or control that opened the dialog. This is best practice for good accessibility. Here are some details on the implementation:
mwc-dialog
becomes the fallback in case of failureLimitations
dialog-closed
event. The majority of the 70+ dialogs do, but about 20 or so need to be updated in future changes.Type of change
Example configuration
Additional information
Checklist