-
Notifications
You must be signed in to change notification settings - Fork 616
Fix pagelayout stories axe violations #3012
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
e5ccc49
Adding tabIndex to pane and content in CustomStickyHeader story to fi…
radglob 871d6f9
Merge branch 'main' of github.com:primer/react into fix-pagelayout-st…
radglob 00719b1
Merge branch 'main' of github.com:primer/react into fix-pagelayout-st…
radglob 85952d1
Merge commit 'FETCH_HeAD' into fix-pagelayout-stories-axe-violations
radglob 81b73e2
Add role=region, tabIndex and required aria-label when pane overflows.
radglob 2f9121d
Merge branch 'main' of github.com:primer/react into fix-pagelayout-st…
radglob 84a46cf
Fix theme-preval snapshot.
radglob 1d3a7b6
Create wild-snakes-fetch.md
radglob 0432388
Add additional aria-labels to fix errors in other PageLayout stories.
radglob bc86087
Update docs.
radglob 5076e18
Update generated/components.json
radglob d476913
Merge branch 'main' into fix-pagelayout-stories-axe-violations
radglob cfbea70
Merge branch 'main' into fix-pagelayout-stories-axe-violations
radglob 8894628
Merge branch 'main' into fix-pagelayout-stories-axe-violations
radglob 49a99ad
Merge branch 'main' into fix-pagelayout-stories-axe-violations
radglob ea787f2
Merge branch 'main' into fix-pagelayout-stories-axe-violations
radglob 90883a5
Merge branch 'main' into fix-pagelayout-stories-axe-violations
radglob bd0e547
Add useOverflow hook, fix broken story missing aria-label.
radglob File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@primer/react": minor | ||
--- | ||
|
||
Adds `tabIndex` and `role="region"` to `PageLayout.Pane` when overflow is detected (scrollHeight > clientHeight). Also requires either `aria-labelledby` or `aria-label` when overflow is detected, and throws an error if neither is defined. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import {useEffect, useState} from 'react' | ||
|
||
export function useOverflow<T extends HTMLElement>(ref: React.RefObject<T>) { | ||
const [hasOverflow, setHasOverflow] = useState(false) | ||
|
||
useEffect(() => { | ||
if (ref.current === null) return | ||
|
||
const observer = new ResizeObserver(entries => { | ||
for (const entry of entries) { | ||
setHasOverflow( | ||
entry.target.scrollHeight > entry.target.clientHeight || entry.target.scrollWidth > entry.target.clientWidth, | ||
) | ||
} | ||
}) | ||
|
||
observer.observe(ref.current) | ||
return () => { | ||
observer.disconnect() | ||
} | ||
}, [ref]) | ||
|
||
return hasOverflow | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.