question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

Dialog's focus lock prevents iframe from having focus

See original GitHub issue

šŸ› Bug report

Imagine a focus-locked area of a web page (in this case a reach-ui dialog). Then we open an iframe thatā€™s actually mounted outside of the focus-locked area, though visually it appears as a dialog itself (though this iframe is not using @reach/dialog, the part that is focus-locked is what is really a @reach/dialog in this example).

See codesandbox example linked to below.

Current Behavior

The focus-locked @reach/dialog instance is too aggressive in keeping the focus for itself, preventing the iframe from having it.

Expected behavior

I understand the current behavior. But Iā€™d like that @reach/dialog would allow me to tell it otherwise.

Reproducible example

CodeSandbox Template

Try to type inside the Wikipedia search field that opens inside the iframe.

Suggested solution(s)

Maybe by exposing the whilelist prop of the react focus lock somehow.

Additional context

Related to #536. That one fixed the case where the focus-locked area is inside an iframe, and was preventing from accessing things outside the iframe. However, this case is when the focus locked area is outside the iframe, and prevents focus from being set to things inside an iframe.

Your environment

Software Name(s) Version
Reach Package dialog 0.10.3
React 16.13.1
Browser Chrome, Firefox latest
Assistive tech
Node
npm/yarn
Operating System

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
gnapsecommented, Jun 17, 2020

@chancestrickland I opened a PR. Iā€™m sure itā€™ll have some things to be improved or added (e.g. I did not add new tests or had to modify any, but I also did not see any tests about focus lock). Iā€™m also not sure if the PR should be involved with documenting this in the website or elsewhere. I added a relatively acceptable documentation to the prop jsdoc, and the examples on how to use the new feature responsibly are in a new storybook example.

1reaction
chaancecommented, Jun 16, 2020

@gnapse The contribution is welcome!

Iā€™d probably go with dangerouslyBypassFocusLock, set to false by default. We definitely donā€™t want to encourage its use in the majority of cases. Iā€™d like to add some documentation about why this is dangerous and should be avoided in most cases, and include an example showing how a custom focus lock can be added to the composed dialog. Happy to help with this if you run into any issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

li a:focus, Prevent Focus Loss when i click in iframe
The :focus pseudo-class is used to style elements as long as it has received focus, either by clicking on it or using the...
Read more >
Dialog Focus in Screen Readers - Adrian Roselli
You probably don't want to put focus on a control if it has a destructive impact; putting focus on cancel or close button...
Read more >
A CSS Approach to Trap Focus Inside of an Element
Unfortunately, trapping focus is only part of the solution when it comes to making modals accessible. A modal dialog should prevent the userĀ ......
Read more >
Accessible dialog tutorial - ally.js
The user is made to focus on the dialog's content and ignore the rest of the application or website. Visually this is usually...
Read more >
ARIA: dialog role - Accessibility - MDN Web Docs - Mozilla
Focus management Ā· Dialogs should always have at least one focusable control. Ā· When the dialog appears on the screen, keyboard focus (whoseĀ ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found