Skip to content

Commit 55e97a9

Browse files
authored
refactor(VisuallyHidden): update base element from div to span (#4691)
* refactor(VisuallyHidden): use span by default over div * refactor(VisuallyHidden): update base element from div to span * chore: add changesets --------- Co-authored-by: Josh Black <joshblack@users.noreply.github.com>
1 parent 546803e commit 55e97a9

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

.changeset/thick-jars-count.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': minor
3+
---
4+
5+
Update internal VisuallyHidden helper to use a `span` by default over a `div` to support more nesting scenarios by default

packages/react/src/Spinner/Spinner.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,7 @@ function Spinner({size: sizeKey = 'medium', srText = 'Loading', 'aria-label': ar
5757
vectorEffect="non-scaling-stroke"
5858
/>
5959
</svg>
60-
{hasHiddenLabel ? (
61-
<VisuallyHidden as="span" id={labelId}>
62-
{srText}
63-
</VisuallyHidden>
64-
) : null}
60+
{hasHiddenLabel ? <VisuallyHidden id={labelId}>{srText}</VisuallyHidden> : null}
6561
</Box>
6662
)
6763
}

packages/react/src/internal/components/VisuallyHidden.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import sx from '../../sx'
1212
*
1313
* @see https://www.scottohara.me/blog/2023/03/21/visually-hidden-hack.html
1414
*/
15-
export const VisuallyHidden = styled.div<SxProp>`
15+
export const VisuallyHidden = styled.span<SxProp>`
1616
&:not(:focus):not(:active):not(:focus-within) {
1717
clip-path: inset(50%);
1818
height: 1px;

0 commit comments

Comments
 (0)