Trap Focus Plugin improved #2057
Replies: 6 comments 19 replies
-
The current x-trap mimics the inert specs, I think: https://html.spec.whatwg.org/multipage/interaction.html#inert |
Beta Was this translation helpful? Give feedback.
-
Here's a browser-friendly version of the directive that @SimoTod mentioned. It's made by @ I updated it to allow outside clicks so things like
Here's the original: https://github.com/MuzafferDede/alpine/blob/e8416300f8826b16bbb91cb171766866c3d662b0/packages/trap/src/index.js |
Beta Was this translation helpful? Give feedback.
-
Can subscribe summarize exactly what changes should be made to x-trap? |
Beta Was this translation helpful? Give feedback.
-
Caleb, i have a PR ready to push that contains all the changes. I am cleaning up the code. |
Beta Was this translation helpful? Give feedback.
-
One small thing, the WAI-ARIA Authoring Practices examples aren't actually
a standard (compared to say, the HTML5 standard, or WCAG 2.1), they're just
examples of pretty good technical implementations. They're a bit out of
date now (e.g. lacking notes on mobile/touch behaviour) but they still
mostly stand up as examples of minimum/baseline behaviour that authors can
then improve on.
I think the vast majority of the focus trap implementations in standalone
projects like focus-trap, but also in libraries/frameworks constrain
tabbing to within the document, so the address bar and other browser UI
(e.g. back/forward buttons and any items in a bookmark bar) are out of
bounds. I think we should match this precedent. Would it be helpful if I
went through a bunch of different frameworks/libraries and noted down which
allow tabbing out of the focus trap to the address bar, and which ones
don't?
An important thing with accessibility is to try and be as predictable as
possible and match what people are used to from other sites, rather than
guess at how keyboard-only users (for example) might think and have your
site/app behave in an unpredictable/different way. I think us guessing that
they might want to exit the focus trapped modal/menu and access the address
bar via the Tab key (rather than use a keyboard shortcut) is an example of
the sort of thinking that it'd be safer to avoid.
…On Mon, 20 Sep 2021, 9:04 am Stratienco Alexandru, ***@***.***> wrote:
*What is a practical example of where the standard-abiding behavior is
better?*
No one says that standard behavior is better or not, but it's a standard
and we should respect that because people who use this kind of navigation
are used to this behavior.
I do not use keyboard navigation but I'm trying to apply the standard as
it is, otherwise it's not standard.
I believe that most of the people who use keyboard navigation know about
CMD/CTRL+L, and maybe that's why the standard is not to jump in URL in a
trap state because they have a short command to jump in URL if they want.
If you want to change a standard behavior I think it's better to go to the
source (W3) and change it there.
But to change it against a standard way, *it's like someone believes that
in America it's a better way to drive on the left side of the road, and he
goes on the left side with his car.*
This is a good way of thinking and acting??
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2057 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABQL2DPLWPRDC5X2KE74ADTUC3TKPANCNFSM5D5FBECA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Beta Was this translation helpful? Give feedback.
-
Oops, I replied before I saw Caleb's response! :)
…On Mon, 20 Sep 2021, 2:55 pm Caleb Porzio, ***@***.***> wrote:
Haha, again, I understand the standards point. However, if an American
thought it was better to drive on the left side of the road, they would die
- that's a pretty practical reason for driving on the right side of the
road - not just abiding to standards lol.
Either way, moving forward with this.
I'm using inert because it was recommended in "Inclusive Components", a
great resource on accessibility:
[image: image]
<https://user-images.githubusercontent.com/3670578/134012317-0a8a78f7-42dd-4cf5-955c-d1d965cd114f.png>
(https://inclusive-components.design/)
After writing a whole paragraph defending the current implementation, I
think the new one is better anyways. I'll merge that PR now.
Thanks for helping me think through this! And thanks @MuzafferDede
<https://github.com/MuzafferDede> for the PR!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2057 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABQL2DNCW5MAFAXL2MQSH4DUC44MHANCNFSM5D5FBECA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Beta Was this translation helpful? Give feedback.
-
I'm struggling to modify the plugin to actually trap focus.
Right now focus is not completely trapped, it's bleeding outside in the URL bar, and it's not the correct way based on what w3.org says : W3.org-ARIA Practices Dialog modal trap focus
I do not fully understand how the plugin works, and hope someone will help me to improve or to add some parameter x-trap.strict to fully comply with w3.org ARIA.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions