Comments (3)
Hello Bogdan!
Thank you for opening an issue and my apologies for leaving it unanswered for so long. It’s quite a nifty case you have here. Have you tried using the data-a11y-dialog-ignore-focus-trap
attribute as mentioned in the documentation, in order to circumvent the focus restoration? You may have to patch the focus behavior yourself, but it seems like it should be doable?
from a11y-dialog.
Hello @KittyGiraudel ,
We would also like a way to skip the focus restoration on dialog dismiss.
We have one set of dialogs that are triggered by a focused input box (not the best idea, I know), and when they are dismissed, the focus restoration triggers them to open again.
As a workround, we've created another data attribute for the dialog container, and in hide()
we skip the focus call if it is found.
Basically this:
if (!this.$el.hasAttribute('data-a11y-dialog-skip-focus-return')) {
this.previouslyFocused?.focus();
}
from a11y-dialog.
Generally speaking, I am a little weary of adding an explicit way to opt-out from the focus restoration — it’s such an important part of building an accessible dialog, and one of the key points of a11y-dialog. There are very few cases where it should be needed (and as you said, most of them are not a good idea), so I’m hesitant in adding more code for that.
I tend to think that the data-a11y-dialog-ignore-focus-trap
escape hatch and some custom JS logic is enough for these weird cases, but maybe I’m wrong of course.
from a11y-dialog.
Related Issues (20)
- Close button doesn't work when added after modal shown HOT 5
- ES6-only version HOT 1
- Public property shown not defined in the typescript definition file d.ts HOT 3
- Reconsider using aria-hidden instead of aria-modal HOT 6
- Dialog doesn't prevent tabbing around the page behind the dialog HOT 3
- [Questions] questions from a curious student HOT 5
- Docs: interface for 'show' event listener callback is incorrect HOT 2
- `description` meta thrown off by <code> tag and < HOT 3
- Consider stopping propagation on capturing the ESC keydown HOT 7
- Usage inside custom component (<template>) HOT 3
- How does it compare with the <dialog> element? HOT 1
- How to get distribution files HOT 2
- Option to disable focus trap completely ? HOT 5
- Document-level click event listening breaks inside web components HOT 13
- keyboard events inside custom element w/stenciljs HOT 2
- Package.json has type: module but main still points at commonjs HOT 5
- Consider implementing the 'shown' and 'hidden' events to facilitate animations HOT 2
- [Discussion] Can popover api be utilized in a11y-dialog? HOT 2
- Custom event to assist with escape key conflicts HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from a11y-dialog.