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

fix(dialog, dialog-full-screen, sidebar): make overflowing content tabbale #7052

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tomdavies73
Copy link
Contributor

@tomdavies73 tomdavies73 commented Nov 1, 2024

fix #6999

Proposed behaviour

When any of the components' content containers overflow and contain no interactive elements, the container will be added to the tabbing order and can be focused via keyboard navigation to ensure their contents are accessible.

Current behaviour

Currently, some overflowing content is inaccessible due to being in an overflowing container with no interactive elements.

Checklist

  • Commits follow our style guide
  • Related issues linked in commit messages if required
  • Screenshots are included in the PR if useful
  • All themes are supported if required
  • Unit tests added or updated if required
  • Playwright automation tests added or updated if required
  • Storybook added or updated if required
  • Translations added or updated (including creating or amending translation keys table in storybook) if required
  • Typescript d.ts file added or updated if required
  • Related docs have been updated if required

QA

  • Tested in provided StackBlitz sandbox/Storybook
  • Add new Playwright test coverage if required
  • Carbon implementation matches Design System/designs
  • UI Tests GitHub check reviewed if required

Additional context

Testing instructions

@tomdavies73 tomdavies73 requested review from a team as code owners November 1, 2024 16:20
@tomdavies73 tomdavies73 changed the title fix(dialog, dialog-full-screen, sidebar): make overflowing content ta… fix(dialog, dialog-full-screen, sidebar): make overflowing content tabbale Nov 1, 2024
@tomdavies73 tomdavies73 self-assigned this Nov 1, 2024
@tomdavies73 tomdavies73 marked this pull request as draft November 1, 2024 16:22
@edleeks87 edleeks87 self-requested a review November 4, 2024 10:12
Copy link
Contributor

@damienrobson-sage damienrobson-sage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Copy link
Contributor

@edleeks87 edleeks87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really good stuff @tomdavies73 👏


elements.push(...focusableElements);

const scrollableElements = Array.from(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment: I don't think we need to have an array here as it will only ever return one or zero elements with how are modals are currently structured. We may also be able to use contains to check if the found element contains anything focusable

const scrollableElement = ref.querySelector(defaultScrollableSelectors);

if (!scrollableElement) {
  return;
}

if (
  scrollableElement.scrollHeight > scrollableElement.clientHeight && 
  (window.getComputedStyle(scrollableElement).overflowY === "scroll" || 
  window.getComputedStyle(scrollableElement).overflowY === "auto") &&
  !focusableElements.some(el => scrollableElement.contains(el))
) {
   scrollableElement.setAttribute("tabindex", "0");
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy for this to be non-blocking if you find any issues or prefer your way as as far as I can tell it works etc

@@ -5,6 +5,9 @@ type CustomRefObject<T> = {
const defaultFocusableSelectors =
'button:not([disabled]), [href], input:not([type="hidden"]):not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]';

const defaultScrollableSelectors =
'div[data-role="sidebar-content"], div[data-role="dialog-content"], div[data-role="dialog-full-screen-content"]';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (non-blocking): it might be worth using data-component here so we're consistent with the other DOM query based implementations we have

edleeks87
edleeks87 previously approved these changes Nov 7, 2024
@edleeks87 edleeks87 marked this pull request as ready for review November 7, 2024 14:02
…bbable

When any of the components' content containers overflow and contain no interactive
elements, the container will be added to the tabbing order and can be focused via
keyboard navigation to ensure their contents are accessible

fix #6999
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Text situated in a Sidebar component can have screen reader issues
3 participants