Skip to content

Commit

Permalink
refactor(VisuallyHidden): update base element from div to span (#4691)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
joshblack and joshblack authored Jun 27, 2024
1 parent 546803e commit 55e97a9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/thick-jars-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': minor
---

Update internal VisuallyHidden helper to use a `span` by default over a `div` to support more nesting scenarios by default
6 changes: 1 addition & 5 deletions packages/react/src/Spinner/Spinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ function Spinner({size: sizeKey = 'medium', srText = 'Loading', 'aria-label': ar
vectorEffect="non-scaling-stroke"
/>
</svg>
{hasHiddenLabel ? (
<VisuallyHidden as="span" id={labelId}>
{srText}
</VisuallyHidden>
) : null}
{hasHiddenLabel ? <VisuallyHidden id={labelId}>{srText}</VisuallyHidden> : null}
</Box>
)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/internal/components/VisuallyHidden.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import sx from '../../sx'
*
* @see https://www.scottohara.me/blog/2023/03/21/visually-hidden-hack.html
*/
export const VisuallyHidden = styled.div<SxProp>`
export const VisuallyHidden = styled.span<SxProp>`
&:not(:focus):not(:active):not(:focus-within) {
clip-path: inset(50%);
height: 1px;
Expand Down

0 comments on commit 55e97a9

Please sign in to comment.