Skip to content

Commit bcbf47c

Browse files
author
Luke Bowerman
authored
fix(Listitem): Improved strategy for :focus-visible CSS (remove z-index from MenuHeading)
- Increased :focus-visible box-shadow on AccordionDisclosure to 2px to match ListItem box-shadow sizing
1 parent fe30da9 commit bcbf47c

File tree

3 files changed

+16
-23
lines changed

3 files changed

+16
-23
lines changed

packages/components/src/Accordion/AccordionDisclosure.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,19 @@ export const AccordionDisclosureStyle = styled.div
144144
color ? colorStyleFn : `color: ${theme.colors.ui5};`}
145145
cursor: pointer;
146146
display: flex;
147-
outline: 1px solid transparent;
148-
outline-color: ${({ focusVisible, theme }) =>
149-
focusVisible && theme.colors.keyFocus};
150147
${padding}
148+
outline: none;
151149
text-align: left;
152150
width: 100%;
153-
`
151+
152+
${({ focusVisible, theme }) =>
153+
focusVisible &&
154+
`
155+
&:focus {
156+
box-shadow: inset 0 0 0 2px ${theme.colors.keyFocus};
157+
}
158+
`}
159+
`
154160

155161
export const AccordionDisclosure = styled(AccordionDisclosureInternal).attrs(
156162
(props) => ({

packages/components/src/List/ListItemWrapper.tsx

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -101,26 +101,17 @@ export const ListItemWrapper = styled(ListItemWrapperInternal)`
101101
&:hover,
102102
&:focus {
103103
color: inherit;
104-
position: relative;
105104
text-decoration: none;
106105
}
107106
}
108107
109-
${({ focusVisible, theme: { colors } }) =>
108+
${({ focusVisible, theme }) =>
110109
focusVisible &&
111-
`&:focus-within > button:after,
112-
&:focus-within > a:after {
113-
content: '';
114-
display:block;
115-
border: solid 2px ${colors.keyFocus};
116-
border-radius: 2px;
117-
margin: 0 1px;
118-
position: absolute;
119-
top: 0;
120-
left: 0;
121-
right: 0;
122-
bottom: 0;
123-
}
110+
`
111+
&:focus-within > button,
112+
&:focus-within > a {
113+
box-shadow: inset 0 0 0 2px ${theme.colors.keyFocus};
114+
}
124115
`}
125116
126117
${Icon} {

packages/components/src/Menu/MenuHeading.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,4 @@ const MenuHeadingWrapper = styled.li<MenuHeadingWrapperProps>`
9797
renderBoxShadow ? `0 4px 8px -2px ${colors.ui2}` : 'none'};
9898
position: sticky;
9999
top: -1px;
100-
/* Prevents a conflict with position: relative items
101-
(which have an additional stacking-context) from
102-
creating a problematic rendering */
103-
z-index: 2;
104100
`

0 commit comments

Comments
 (0)