Skip to content

[combobox][menu] Fix onClick Item type - #3964

Merged
atomiks merged 1 commit into
mui:masterfrom
atomiks:codex/issue-3949-prevent-base-ui-handler
Feb 4, 2026
Merged

atomiks merged 1 commit into
mui:masterfrom
atomiks:codex/issue-3949-prevent-base-ui-handler

Conversation

@atomiks

@atomiks atomiks commented Feb 4, 2026

Copy link
Copy Markdown
Contributor

Fixes #3949

@atomiks atomiks added component: menu Changes related to the menu component. type: bug It doesn't behave as expected. typescript component: combobox Changes related to the combobox component. labels Feb 4, 2026
@pkg-pr-new

pkg-pr-new Bot commented Feb 4, 2026 •

Copy link
Copy Markdown
  • base-ui-tanstack-start

  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/react@3964
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@3964
    

commit: 9ef6fce

@mui-bot

mui-bot commented Feb 4, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Feb 4, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 9ef6fce
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/698301837ba782000872b138
😎 Deploy Preview https://deploy-preview-3964--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@atomiks
atomiks force-pushed the codex/issue-3949-prevent-base-ui-handler branch from 81d49b3 to 693f395 Compare February 4, 2026 08:18
[combobox,menu] Fix onClick handler types
@atomiks
atomiks force-pushed the codex/issue-3949-prevent-base-ui-handler branch from 693f395 to 9ef6fce Compare February 4, 2026 08:21
@atomiks
atomiks marked this pull request as ready for review February 4, 2026 08:21
@greptile-apps

greptile-apps Bot commented Feb 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

This PR fixes the type signature of the onClick prop for Combobox and Menu item components to properly support the preventBaseUIHandler() method. Previously, the onClick prop was typed as React.MouseEventHandler<HTMLElement>, which provides standard React synthetic events. The change updates it to use BaseUIComponentProps<'div', State>['onClick'], which wraps the event with BaseUIEvent that includes the preventBaseUIHandler() method.

Key changes:

  • Updated onClick type in ComboboxItem, MenuItem, MenuCheckboxItem, MenuRadioItem, and MenuSubmenuTrigger
  • Added test cases verifying preventBaseUIHandler() works correctly in both combobox and menu contexts
  • Moved MenuSubmenuTriggerState interface definition before MenuSubmenuTriggerProps to avoid forward reference issues
  • Regenerated API documentation JSON files to reflect the updated type signatures

The implementation is consistent with Base UI's event handling pattern where user-provided handlers execute first and can prevent the library's default behavior by calling event.preventBaseUIHandler(). This is handled by the mergeProps utility which merges event handlers and respects the prevention flag.

Confidence Score: 5/5

  • This PR is safe to merge with no issues found
  • The changes are straightforward type updates that align the onClick prop signature with Base UI's event handling system. Test coverage confirms the functionality works as expected. The refactoring in MenuSubmenuTrigger.tsx (moving the State interface) is necessary and correct.
  • No files require special attention

Important Files Changed

Filename Overview
packages/react/src/combobox/item/ComboboxItem.tsx Updated onClick type from React.MouseEventHandler<HTMLElement> to BaseUIComponentProps<'div', ComboboxItemState>['onClick'] to properly support preventBaseUIHandler
packages/react/src/combobox/item/ComboboxItem.test.tsx Added test case verifying that calling event.preventBaseUIHandler() in onClick handler prevents item selection
packages/react/src/menu/item/MenuItem.tsx Updated onClick type from React.MouseEventHandler<HTMLElement> to BaseUIComponentProps<'div', MenuItemState>['onClick'] to properly support preventBaseUIHandler
packages/react/src/menu/item/MenuItem.test.tsx Added test case verifying that calling event.preventBaseUIHandler() in onClick handler prevents menu from closing
packages/react/src/menu/submenu-trigger/MenuSubmenuTrigger.tsx Updated onClick type and moved MenuSubmenuTriggerState interface definition before MenuSubmenuTriggerProps to fix forward reference

@atomiks
atomiks merged commit 08214ff into mui:master Feb 4, 2026
8 checks passed
@atomiks
atomiks deleted the codex/issue-3949-prevent-base-ui-handler branch February 4, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: combobox Changes related to the combobox component. component: menu Changes related to the menu component. type: bug It doesn't behave as expected. typescript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[combobox] Incorrect type for onClick on ComboboxItem

3 participants