Skip to content
This repository was archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
[terra-application-header-layout, terra-layout] Fix for the "Skip to …
Browse files Browse the repository at this point in the history
…content" button accessibility issue (#2105)
  • Loading branch information
user099 authored Mar 27, 2024
1 parent 9035f5e commit 0ef2aad
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Cerner Corporation
- Kol Kheang [@kolkheang]
- Aaron Johnson [@zxeleven]
- Serhii Pavlov [@sPavl0v]
- Dmytro Smoliakov [@user099]

[@tbiethman]: https://github.com/tbiethman
[@mjhenkes]: https://github.com/mjhenkes
Expand Down Expand Up @@ -103,3 +104,4 @@ Cerner Corporation
[@kolkheang]: https://github.com/kolkheang
[@zxeleven]: https://github.com/zxeleven
[@sPavl0v]: https://github.com/sPavl0v
[@user099]: https://github.com/user099
3 changes: 3 additions & 0 deletions packages/terra-application-header-layout/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

* Changed
* "Skip to content" button's logic that adds and removes `tabindex` attribute for the main element was removed to fix unexpected focus behavior for users using screen readers.

## 3.40.0 - (December 18, 2023)

* Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ const ApplicationHeaderLayout = ({
const mainContainer = document.querySelector(['[data-terra-layout-main]']);

if (mainContainer) {
mainContainer.setAttribute('tabindex', '-1');
mainContainer.focus();
mainContainer.removeAttribute('tabindex');
}
};

Expand Down
2 changes: 2 additions & 0 deletions packages/terra-layout/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Changelog

## Unreleased
* Changed
* `tabindex` attribute with value `-1` was added to the main element (`data-terra-layout-main`) to fix unexpected focus behavior for users using screen readers.

## 4.39.0 - (December 18, 2023)

Expand Down
2 changes: 1 addition & 1 deletion packages/terra-layout/src/_LayoutSlidePanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class LayoutSlidePanel extends React.Component {
</div>
<OverlayContainer className={cx('content')}>
<Overlay isRelativeToContainer onRequestClose={onToggle} isOpen={isOverlayOpen} backgroundStyle={overlayBackground} zIndex="6000" />
<main role="main" data-terra-layout-main className={cx('main-container')}>
<main role="main" tabIndex="-1" data-terra-layout-main className={cx('main-container')}>
{children}
</main>
</OverlayContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ exports[`LayoutSlidePanel correctly applies the theme context className 1`] = `
className="main-container"
data-terra-layout-main={true}
role="main"
tabIndex="-1"
/>
</div>
</div>
Expand Down Expand Up @@ -83,6 +84,7 @@ exports[`LayoutSlidePanel should render when small 1`] = `
className="main-container"
data-terra-layout-main={true}
role="main"
tabIndex="-1"
>
<div>
Child
Expand Down Expand Up @@ -121,6 +123,7 @@ exports[`LayoutSlidePanel should render when tiny 1`] = `
className="main-container"
data-terra-layout-main={true}
role="main"
tabIndex="-1"
>
<div>
Child
Expand Down Expand Up @@ -159,6 +162,7 @@ exports[`LayoutSlidePanel should render with provided props 1`] = `
className="main-container"
data-terra-layout-main={true}
role="main"
tabIndex="-1"
>
<div>
Child
Expand Down Expand Up @@ -192,6 +196,7 @@ exports[`LayoutSlidePanel should render without optional props 1`] = `
className="main-container"
data-terra-layout-main={true}
role="main"
tabIndex="-1"
/>
</OverlayContainer>
</div>
Expand Down

0 comments on commit 0ef2aad

Please sign in to comment.