Skip to content

Commit

Permalink
fix: apply focus styles to <li> tag
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrikThePendric committed Nov 26, 2024
1 parent a91c77b commit 822af60
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
16 changes: 16 additions & 0 deletions components/menu/src/menu-item/menu-item.prod.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,22 @@ Icon.parameters = {
},
}

export const InContainer = (args) => {
return (
<div
style={{
height: 40,
width: 300,
overflow: 'hidden',
}}
>
<Menu {...args}>
<MenuItem label="Menu item" />
</Menu>
</div>
)
}

export const Suffix = Template.bind({})
Suffix.args = {
label: 'Open in Data Visualizer',
Expand Down
17 changes: 9 additions & 8 deletions components/menu/src/menu-item/menu-item.styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ export default css`
background-color: ${colors.white};
}
/*focus-visible backwards compatibility for safari: https://css-tricks.com/platform-news-using-focus-visible-bbcs-new-typeface-declarative-shadow-doms-a11y-and-placeholders/*/
li:focus {
outline: 3px solid ${theme.focus};
outline-offset: -3px;
}
li:focus:not(:focus-visible) {
outline: none;
}
a {
display: inline-flex;
flex-grow: 1;
Expand All @@ -58,14 +67,6 @@ export default css`
text-decoration: none;
color: inherit;
}
/*focus-visible backwards compatibility for safari: https://css-tricks.com/platform-news-using-focus-visible-bbcs-new-typeface-declarative-shadow-doms-a11y-and-placeholders/*/
a:focus {
outline: 3px solid ${theme.focus};
outline-offset: -3px;
}
a:focus:not(:focus-visible) {
outline: none;
}
li.with-chevron a {
padding-inline-end: ${spacers.dp8};
Expand Down

0 comments on commit 822af60

Please sign in to comment.