Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Details/summary focus trapping allows user to tab to summary element outside of drawer #360

Open
KaichenWang opened this issue Aug 10, 2021 · 1 comment
Labels
Category: Bug Something isn't working Effort: Low Severity: 3 Normal/Low Severity

Comments

@KaichenWang
Copy link
Contributor

KaichenWang commented Aug 10, 2021

Describe the current behavior

When a details/summary is open, JS traps focus to the focusable descendants of the details element. The summary element is part of the focusable elements, but this is not always desired. For example when the mobile filtering drawer is opened, the user can tab to the summary element, which is "behind" the modal.

Describe the expected behavior

Trapped focus does not allow user to tab to outside of drawer when it is open.

Version information (Dawn, browsers and operating systems)

  • Dawn Version: 1.1.0
  • Chrome Version Version 92.0.4515.131
  • macOS Version 11.4

Possible solution

Trap focus includes summary elements in its list of focusable elements. This may be too generic of a selector since we won't always want to include summary as a focusable element.

function getFocusableElements(container) {
  return Array.from(
    container.querySelectorAll(
      "summary, a[href], button:enabled, [tabindex]:not([tabindex^='-']), [draggable], area, input:not([type=hidden]):enabled, select:enabled, textarea:enabled, object, iframe"
    )
  );
}

Additional context/screenshots
n/a

@KaichenWang KaichenWang changed the title Details/summary focus trapping Details/summary focus trapping allows user to tab to summary element outside of drawer Aug 10, 2021
@KaichenWang KaichenWang added Category: Bug Something isn't working Effort: Low labels Aug 10, 2021
@tyleralsbury tyleralsbury added the Severity: 1 Urgent Severity label Aug 11, 2021
@nicklepine nicklepine added Severity: 2 High Severity and removed Severity: 1 Urgent Severity labels Aug 18, 2021
@nicklepine nicklepine added Severity: 3 Normal/Low Severity and removed Severity: 2 High Severity labels Jan 7, 2022
@kmeleta
Copy link
Contributor

kmeleta commented Apr 5, 2023

Should have checked for this issue first.. I may have just opened a dupe, but I added some more observations that might be useful or more relevant to the header and to the current Dawn version #2496

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Bug Something isn't working Effort: Low Severity: 3 Normal/Low Severity
Projects
None yet
Development

No branches or pull requests

4 participants