forked from WordPress/gutenberg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix screen readers not announcing updated
aria-describedby
in Firef…
…ox (WordPress#51035) * Fix aria-describedby not updating content * Try aria-description. * Try a different approach * Fix missing prop --------- Co-authored-by: Alex Stine <[email protected]>
- Loading branch information
1 parent
bba52a3
commit 97e3972
Showing
4 changed files
with
36 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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
30 changes: 30 additions & 0 deletions
30
packages/block-editor/src/components/list-view/aria-referenced-text.js
This file contains 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,30 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useRef, useEffect } from '@wordpress/element'; | ||
|
||
/** | ||
* A component specifically designed to be used as an element referenced | ||
* by ARIA attributes such as `aria-labelledby` or `aria-describedby`. | ||
* | ||
* @param {Object} props Props. | ||
* @param {import('react').ReactNode} props.children | ||
*/ | ||
export default function AriaReferencedText( { children, ...props } ) { | ||
const ref = useRef(); | ||
|
||
useEffect( () => { | ||
if ( ref.current ) { | ||
// This seems like a no-op, but it fixes a bug in Firefox where | ||
// it fails to recompute the text when only the text node changes. | ||
// @see https://github.com/WordPress/gutenberg/pull/51035 | ||
ref.current.textContent = ref.current.textContent; | ||
} | ||
}, [ children ] ); | ||
|
||
return ( | ||
<div hidden { ...props } ref={ ref }> | ||
{ children } | ||
</div> | ||
); | ||
} |
This file contains 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 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