2b89989f62
fix(ui): add onSelect compat wrapper for DropdownMenuItem Bridges Base UI DropdownMenu with Radix-style onSelect so existing consumers work without migration.
26 lines
580 B
TypeScript
Vendored
26 lines
580 B
TypeScript
Vendored
import type * as React from 'react'
|
|
|
|
export type DropdownMenuItemSelectEvent = React.MouseEvent<HTMLElement> & {
|
|
preventBaseUIHandler?: () => void
|
|
}
|
|
|
|
export type DropdownMenuItemSelectHandler = (
|
|
event: DropdownMenuItemSelectEvent
|
|
) => void
|
|
|
|
export function handleDropdownMenuItemSelect(
|
|
event: DropdownMenuItemSelectEvent,
|
|
onClick?: React.MouseEventHandler<HTMLElement>,
|
|
onSelect?: DropdownMenuItemSelectHandler
|
|
) {
|
|
onClick?.(event)
|
|
|
|
if (!event.defaultPrevented) {
|
|
onSelect?.(event)
|
|
}
|
|
|
|
if (event.defaultPrevented) {
|
|
event.preventBaseUIHandler?.()
|
|
}
|
|
}
|