Skip to content

Commit

Permalink
Add explicit type-parameter to event-handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
kraenhansen committed Dec 27, 2024
1 parent 884419c commit 9ea67d3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/menu/src/SubMenu/SubMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ export const SubMenu = InferredPolymorphic<InternalSubMenuProps, 'button'>(
const submenuTriggerRef = useRef<HTMLButtonElement>(null);
const subMenuHeight = useChildrenHeight(submenuRef, [open]);

const handleClick: MouseEventHandler = e => {
const handleClick: MouseEventHandler<
HTMLAnchorElement & HTMLButtonElement
> = e => {
if (onClick || rest.href) {
if (!disabled) {
onClick?.(e);
Expand Down
8 changes: 6 additions & 2 deletions packages/split-button/src/Menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ export const Menu = ({
useBackdropClick(handleClose, [buttonRef, menuRef], open);

const renderMenuItems = useMemo(() => {
const onMenuItemClick = (e: MouseEvent, menuItem: MenuItemType) => {
const onMenuItemClick = (
e: MouseEvent<HTMLAnchorElement & HTMLButtonElement>,
menuItem: MenuItemType,
) => {
handleClose();
menuItem.props.onClick?.(e);
onChange?.(e);
Expand All @@ -90,7 +93,8 @@ export const Menu = ({
return React.cloneElement(menuItem, {
active: false,
key: `menuItem-${menuItem.key}`,
onClick: (e: MouseEvent) => onMenuItemClick(e, menuItem),
onClick: (e: MouseEvent<HTMLAnchorElement & HTMLButtonElement>) =>
onMenuItemClick(e, menuItem),
});
} else {
console.warn(
Expand Down

0 comments on commit 9ea67d3

Please sign in to comment.