Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 677
1518 react treeview feedback from screen reader#2710
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
agreenberry
merged 15 commits into
main
from
1518-react-treeview-feedback-from-screen-readerJan 24, 2023
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4fdf6b4
fix(TreeView): remove "folder empty" announcement/logic
agreenberry 72813e4
test(TreeView): added nested subtree to TreeView test
agreenberry 69a54e6
Merge remote-tracking branch 'origin/main' into 1518-react-treeview-f…
agreenberry 2c2763b
chore: update storybook and add changeset
agreenberry 93e7c92
chore: fix lint
agreenberry 1765037
Merge branch 'main' into 1518-react-treeview-feedback-from-screen-reader
agreenberry c067857
Update src/TreeView/TreeView.tsx
agreenberry f02af4f
Update .changeset/rotten-hairs-impress.md
agreenberry aafeb2d
Merge branch 'main' into 1518-react-treeview-feedback-from-screen-reader
agreenberry a76e734
Merge remote-tracking branch 'origin/main' into 1518-react-treeview-f…
agreenberry e22e310
Merge branch 'main' into 1518-react-treeview-feedback-from-screen-reader
agreenberry e10d724
Update .changeset/rotten-hairs-impress.md
agreenberry 8ba6ece
chore: add comment explaining use of isPending
agreenberry 5566f17
Merge branch 'main' into 1518-react-treeview-feedback-from-screen-reader
agreenberry 84825f0
chore: fixed formatting
agreenberry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
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': patch | ||
| --- | ||
| TreeView: aria status description is now accurate |
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 |
|---|---|---|
| @@ -75,7 +75,7 @@ const UlBox = styled.ul<SxProp>` | ||
| * We define styles for the tree items at the root level of the tree | ||
| * to avoid recomputing the styles for each item when the tree updates. | ||
| * We're sacraficing maintainability for performance because TreeView | ||
| * needs to be performant enough to handle large trees (thousands of items). | ||
| * needs to be performant enough to handle large trees (thousands of items). | ||
| * | ||
| * This is intended to be a temporary solution until we can improve the | ||
| * performance of our styling patterns. | ||
| @@ -508,6 +508,13 @@ const SubTree: React.FC<TreeViewSubTreeProps> = ({count, state, children}) => { | ||
| const {safeSetTimeout} = useSafeTimeout() | ||
| const loadingItemRef = React.useRef<HTMLElement>(null) | ||
| const ref = React.useRef<HTMLElement>(null) | ||
| const [isPending, setPending] = React.useState(state === 'loading') | ||
| React.useEffect(() => { | ||
| if (state === 'loading') { | ||
| setPending(true) | ||
| } | ||
| }, [state]) | ||
| React.useEffect(() => { | ||
| // If `state` is undefined, we're working in a synchronous context and need | ||
| @@ -523,9 +530,11 @@ const SubTree: React.FC<TreeViewSubTreeProps> = ({count, state, children}) => { | ||
| } | ||
| }, [state, isSubTreeEmpty, setIsSubTreeEmpty, children]) | ||
| // Announce when content has loaded | ||
| // If a consumer sets state="done" without having a previous state (like `loading`), | ||
| // then it would announce on the first render. Using isPending is to only | ||
| // announce being "loaded" when the state has changed from `loading` --> `done`. | ||
| React.useEffect(() => { | ||
| if (state === 'done') { | ||
| if (isPending && state === 'done') { | ||
agreenberry marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| const parentItem = document.getElementById(itemId) | ||
| if (!parentItem) return | ||
| @@ -540,8 +549,10 @@ const SubTree: React.FC<TreeViewSubTreeProps> = ({count, state, children}) => { | ||
| announceUpdate(`${parentName} is empty`) | ||
| } | ||
| }) | ||
| setPending(false) | ||
| } | ||
| }, [state, itemId, announceUpdate, safeSetTimeout]) | ||
| }, [state, itemId, announceUpdate, safeSetTimeout, isPending]) | ||
| // Manage loading indicator state | ||
| React.useEffect(() => { | ||
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.