Skip to content

Commit

Permalink
Shield 794 explore a better way to indicate focused state in checkbox…
Browse files Browse the repository at this point in the history
… and radiofield components (#2832)

* chore: update radio option focus styles

The focus styles now apply only when the option has been keyboard-focused

* chore: update checkbox input focus styles

The focus styles now apply only when the checkbox has been keyboard-focused.

---------

Co-authored-by: Douglas Egiemeh <[email protected]>
  • Loading branch information
misama-ct and ddouglasz authored May 31, 2024
1 parent e790eab commit 42fd117
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/neat-ligers-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@commercetools-uikit/checkbox-input': patch
'@commercetools-uikit/radio-input': patch
---

The focus outline for checkbox and radio labels is now only visible to keyboard users.
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ const Label = styled.label<TLabelProps>`
}};
position: relative;
&:focus-within ${LabelTextWrapper} {
&:focus-within:has(:focus-visible) ${LabelTextWrapper} {
box-shadow: 0 0 0 2px ${designTokens.borderColorForInputWhenFocused};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const RadioOptionLabel = styled.label<TStylesProps>`
${(props) =>
!props.isReadOnly
? `:focus-within ${LabelTextWrapper} {
? `:focus-within:has(:focus-visible) ${LabelTextWrapper} {
outline: auto 2px ${designTokens.borderColorForInputWhenFocused};
outline-offset: 2px;
width: fit-content;
Expand Down

0 comments on commit 42fd117

Please sign in to comment.