-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[FocusTrap] Trap to only focus on tabbable elements #23827
Comments
This comment has been minimized.
This comment has been minimized.
@eps1lon The only difference I see between the current implementation and the PR implementation is when testing is if hit tab again after the 'Cancel' button I land on the sentential. Define 'all elements' please. Because I am not seeing any other element that was accessible being no longer accessible in the PR other than the sentential |
@eps1lon Thanks for providing more details on the limitations of #23364. This helps evaluate the tradeoff. So we have two downsides with the proposed approach:
On the other hand, we have two downsides with the current approach:
Focusing the container is discouraged by WAI-ARIA: @gregnb do you have more details on the negative aspects of the current logic that were reported by the FAAMNG? I don't understand the point about the sentinels, it seems fine. Both approaches use them. What problem did these guys catch? Are they aware of the downsides of the approach we implemented? From my perspective #23364 is a net positive, and that's coming from the one who didn't want to implement it initially in #14545 to save bundle size. It makes the Modal +12% bigger. My imagination fails to see the alternatives available. Thoughts? |
@oliviertassinari the issue is landing on the sentential and then having to hit tab again. Both implementations are fine using two sentential to create a zone, but the current implementation causes a user to land on the sentential and then nothing happens. They have to hit tab again vs the PR which then simply forwards a user to the first tabbable element. Let me share a sample of what these defects read like: "Users who rely on Keyboard for Navigation are getting impacted as the focus is moving on to the Hidden Element after the while navigating using TAB key. User will get confused as the focus is moving on to the hidden element and focus indicator is not visible on any element. " Reference: https://www.w3.org/WAI/WCAG21/Understanding/focus-order.html" |
@gregnb Wait, what, How can it be reproduced? It was never designed to behave like this (nor I have ever seen it behave like this). Maybe the observation is wrong and assumed because there is no focus ring on the Modal container (which resonates with the pain of #23532) |
I believe you are right and I am wrong. Observation is wrong in a way but the details in the ticket are what we are suffering from I see you have the following suggestions from that thread:
|
@gregnb Ok, so if we ignore the technical aspect and focus on the end-user issue reported by the FAAMNG, it's about end-users losing track of where the focus is, downside 1/2 of the current approach:
|
@eps1lon What do you think about this middle ground solution?
It might solve @gregnb's FAAMNG issue (it needs to be checked because it's not perfect) and definitely solve #23532. We would still have two downsides:
|
Kind of worried about this part tbh. I wonder how that is going to play out |
This is something that was raised to me personally when taking part in a wcag 2.1 audit at work. It’s definitely not ideal for screen readers. |
I agree
@oliviertassinari if i boil this down (and they're both broken implementations. ie: current vs PR): PR implementation:
Current implementation:
I'm still at a loss seeing how the current implementation is better |
@eps1lon What do you think about the above :)? So far I felt that you have been opposing the change without contributing significantly to a solution. It you could engage in this follow-up discussion, it would be great. e.g what alterrnative solution did you consider? You suggested that an alternative was possible :). It looks like we have a clear direction from the community. This is a step forward. I plan to apply the changes back in the coming days unless we uncover new important information, leave enough time to get more data. We can also keep integrate in the problem after. |
The problem is that we have two problems and people think they can fix both of them. Neither problem is clearly defined and the solution is proofably wrong. This makes for a disaster which we should absolutely avoid. In addition, it doesn't help if bugs are reported without reproduction. Sentinels being focused is definitely a bug which we need to solve. So if this happens, please follow the standard procedure. With regards to focusing the container: This is the tradeoff we're making if authors are not properly wiring up their dialog by declaring which element should be focused when opened. We could just disable that behavior. This seems like a far less intrusive change. Why not go down this road instead?
It is not. This is not a one-dimensional problem. Both have different problems but at least for the current problem we have a workaround. Your implementation makes that impossible.
Because you are probably using a different user agent than I am using. I don't think anyone acknowledged the spec behavior that user agents are implementing: focus is up to the user agent. However, we do not have an API to ask the user agent if an item is focusable.
I showed you why we can't know which items are tabbable with the APIs that are available to us. It's like I just explained to you what a black hole is and you complain that I'm not contributing to how we can reach the singularity within.
And I will veto them until we actually know what we are doing. This means an extensive set of fixtures that we can test the new approach with different user agent + screen reader combinations. I do not understand why you're forcing this change without acknowledging what I told and showed you. |
You know what, I've got plenty things to do so I'm leaving this up for grabs and wait for the issues to come in how the new approach prevents focusing focusable elements. I did my job by referencing the spec and a reference implementation of that spec (chrome). If people want to ignore me, so be it. |
@eps1lon I think that we all agree on this. The current approach is provable wrong too. So I think that it's about the evaluation of what's the least worse option.
👍 for reporting. So far, we have assumed that the auditor that didn't realize the focus would move to the container, with no outline. If it was truly an issue with focusing the sentinel, I would have expected the auditor to reject the patch we did in #23364 because it relies on it too.
How would the focus round-robing technically work without a container and without inspecting to DOM to determine the tabbable nodes? Would it mean leaving the focus on an invisible sentinel? If you think there is potential, it would be great to see a POC or, even better, an existing implementation in the wild that show the potential :). Nodes can still be focused on when
This point is important. I think that we have acknowledged it by trying to demonstrate how it's OK-ish in practice (with the false-negative and false-positive of the logic that tries to emulate the user-agent behavior with heuristics).
What's the workaround? Applying the same logic by dropping react-focus-lock inside a Modal? Why is it impossible? I believe we have previously demonstrated that the two downsides of #23364 are negligible. false-positive (shouldn't have focused) barely harm and false-negative (should have been focused) can be hedged by 1. manually adding tab-index, 2. providing a custom tabbable logic with the new prop, 3. ignoring it (<10% of frequency) |
I reverted #23364 which is harmful and was merged without having a full picture.
Leaving this issue for visibility until the issue is transparently discussed.
Quick summary why #23364 does not work (or any DOM API approach for that matter):
What is click or keyboard focusable is up to the user agent by specification:
-- https://html.spec.whatwg.org/multipage/interaction.html#focusable-area
This means that any browser is free to break the behavior #23364 implemented. Specifically, #23364 does not support scrollable containers that are keyboard focusable with Chrome 87 on Ubuntu 20.04
Current implementation: https://d7r30.csb.app/
PR (broken) implementation: https://y8e9h.csb.app/
Forward tabbing loops between the two buttons. With the previous implementation all elements were accessible.
The PR being better than nothing is flawed since it replaces (potential) confusion with not being able to access elements at all. I don't think that a UI with excess elements is less accessible than a UI with completely inaccessible elements.
Further reading:
The text was updated successfully, but these errors were encountered: