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.

[Modal] Better focus management

See original GitHub issue

Current(master) focus-management is broken for shift+tab, while forward tapping is also working not as expected, as long as you may leave a modal, and got into browser address line, which is good, but should be impossible.

A new TrapFocus implementation also does not seems to be correct, especially due to the absence of RootRef, used to discover nested portals (like here - https://nk7zmp3900.codesandbox.io/)

  • This is not a v0.x issue.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior 🤔

  • loop then tabbing forward
  • loop then tabbing backwards

Current Behavior 😯

  • loop then tabbing forward, with focus on body and modal after leaving browser address bar - causing 1 or 2 tabs without visible response.
  • does not loop backwards. A new TrapFocus would probably fix it, but might introduce other issues.

Steps to Reproduce 🕹

See an example with 3 buttons inside a modal - https://codesandbox.io/s/j1ll74o3v9

Context 🔦

Sorry, I have a professional deformation 😃 I’ve invested too much time in focus management, and all focus-related problems are visible to me.

Proposed solution

Replace TrapFocus by react-focus-lock, which would handle all edge cases including Portals. There is only one downside of it - +4kb.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
eps1loncommented, Jul 24, 2019

AFAIK - waiting for React Flare.

Same

2reactions
theKasheycommented, Jul 23, 2019

AFAIK - waiting for React Flare.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Modal] Better focus management #15450 - mui/material-ui
[Modal] Better focus management #15450 ; Expected Behavior ; Current Behavior ; Steps to Reproduce ; Context.
Read more >
Focus management | Interface guidelines
Overview. Managing focus within a page or application is essential for users to successfully navigate, complete actions, and understand where they are.
Read more >
Focus management and inert
Focus management is the practice of coordinating what can and cannot ... Keeping focus within a modal communicates its bounds, and helps ...
Read more >
How to trap focus inside modal to make it ADA compliant
tab, shift + tab and enter key and focus should be trapped inside modal and should not go out after pressing tab key...
Read more >
Managing focus for modal dialogs - WCAG WG
Managing focus for modal dialogs · Capturing focus within the modal dialog · Setting focus to the dialog initially, and setting focus correctly...
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