Giter Club home page Giter Club logo

Comments (3)

KittyGiraudel avatar KittyGiraudel commented on August 16, 2024

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.

jlango791 avatar jlango791 commented on August 16, 2024

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.

KittyGiraudel avatar KittyGiraudel commented on August 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.