Skip to content
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

refactor(VisuallyHidden): update base element from div to span #4691

Merged
merged 4 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Loading