Skip to content

Commit

Permalink
Revert "Remove eslint disable from ActionMenu story; edit story t…
Browse files Browse the repository at this point in the history
…o be keyboard accessible (#5341)"

This reverts commit d1dc7fa.
  • Loading branch information
francinelucca committed Dec 5, 2024
1 parent 5c60d08 commit f83f5fb
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/react/src/ActionMenu/ActionMenu.examples.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,22 +235,22 @@ export const ShortcutMenu = () => {

export const ContextMenu = () => {
const ListItemWithContextMenu = ({children}: {children: string}) => {
const handleContextMenu: React.MouseEventHandler<HTMLElement> = event => {
const handleContextMenu: React.MouseEventHandler<HTMLLIElement> = event => {
event.preventDefault()
setOpen(true)
}

const [open, setOpen] = React.useState(false)
const triggerRef = React.useRef<HTMLButtonElement>(null)
const triggerRef = React.useRef<HTMLLIElement>(null)

return (
<li onContextMenu={handleContextMenu}>
// We need to add an aria-label for improving support for more assistive technologies. For example: VoiceOver might not detect the `name` without `aria-label`
// Since this has a custom context menu, it's ok to add a tabIndex
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
<li ref={triggerRef} onContextMenu={handleContextMenu} tabIndex={0} aria-label={children}>
{children}
<ActionMenu open={open} onOpenChange={setOpen} anchorRef={triggerRef}>
<ActionMenu.Anchor>
<Button ref={triggerRef} variant="invisible" onClick={handleContextMenu}>
{children}
</Button>
</ActionMenu.Anchor>
<ActionMenu.Button sx={{visibility: 'hidden', height: 0}}>Anchor</ActionMenu.Button>
<ActionMenu.Overlay>
<ActionList>
<ActionList.Item>
Expand Down

0 comments on commit f83f5fb

Please sign in to comment.