Skip to content
Draft
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
8 changes: 0 additions & 8 deletions oxlint-suppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,6 @@
"count": 4
}
},
"web/app/components/app-sidebar/dataset-info/menu-item.tsx": {
"jsx_a11y/click-events-have-key-events": {
"count": 1
},
"jsx_a11y/no-static-element-interactions": {
"count": 1
}
},
"web/app/components/app/annotation/add-annotation-modal/edit-item/index.tsx": {
"erasable-syntax-only/enums": {
"count": 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,24 @@ describe('MenuItem', () => {
render(<MenuItem name="Edit" Icon={TestEditIcon} handleClick={handleClick} />)

// Act
await user.click(screen.getByText('Edit'))
await user.click(screen.getByRole('button', { name: 'Edit' }))

// Assert
expect(handleClick).toHaveBeenCalledTimes(1)
})

it('should be reachable and activate with the keyboard', async () => {
const user = userEvent.setup()
const handleClick = vi.fn()
render(<MenuItem name="Edit" Icon={TestEditIcon} handleClick={handleClick} />)

await user.tab()
expect(screen.getByRole('button', { name: 'Edit' })).toHaveFocus()

await user.keyboard('{Enter}')
expect(handleClick).toHaveBeenCalledTimes(1)
})

it('should stop propagation before invoking the handler', () => {
const parentClick = vi.fn()
const handleClick = vi.fn()
Expand Down
7 changes: 4 additions & 3 deletions web/app/components/app-sidebar/dataset-info/menu-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ type MenuItemProps = {

const MenuItem = ({ Icon, name, handleClick }: MenuItemProps) => {
return (
<div
className="flex items-center gap-x-1 rounded-lg px-2 py-1.5 hover:bg-state-base-hover"
<button
type="button"
className="flex items-center gap-x-1 rounded-lg px-2 py-1.5 text-start hover:bg-state-base-hover"
onClick={(e) => {
e.preventDefault()
e.stopPropagation()
Expand All @@ -19,7 +20,7 @@ const MenuItem = ({ Icon, name, handleClick }: MenuItemProps) => {
>
<Icon className="size-4 text-text-tertiary" />
<span className="px-1 system-md-regular text-text-secondary">{name}</span>
</div>
</button>
)
}

Expand Down