Skip to content

[combobox] Distinguish input-press from trigger-press in onOpenChange reason - #4015

Merged
atomiks merged 11 commits into
mui:masterfrom
jijiseong:feat/input-reason
Feb 9, 2026
Merged

atomiks merged 11 commits into
mui:masterfrom
jijiseong:feat/input-reason

Conversation

@jijiseong

@jijiseong jijiseong commented Feb 8, 2026 •

Copy link
Copy Markdown
Contributor

closes #4000

Summary

onOpenChange now receives input-press when the combobox popup is opened by the Input.

Changes

  • Add input-press to Reasons.
  • Add optional reason prop to useClick (default triggerPress).
  • Pass input-press into useClick’s reason prop in AriaCombobox.

Question

Is it okay to keep this in useClick (configurable reason)?

@greptile-apps

greptile-apps Bot commented Feb 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

This PR extends the Combobox onOpenChange “reason” system to distinguish openings triggered by pressing the input vs pressing the trigger. It does this by adding a new inputPress reason, wiring that through AriaCombobox interaction handling, and making useClick accept an optional reason override (defaulting to triggerPress). A regression test was added to ensure Combobox.Input press produces inputPress.

Confidence Score: 3/5

  • This PR is mergeable after addressing the useClick reason scoping issue to avoid mislabeling onOpenChange reasons in some click paths.
  • Core changes are small and test-covered for the input-press path, but the new useClick-level reason option appears too coarse-grained if the same hook instance handles both reference and floating clicks; that would cause incorrect reasons to be emitted in real interaction flows.
  • packages/react/src/floating-ui-react/hooks/useClick.ts; packages/react/src/combobox/root/AriaCombobox.tsx

Important Files Changed

Filename Overview
packages/react/src/combobox/input/ComboboxInput.test.tsx Adds a regression test asserting onOpenChange reason is inputPress when opening via Combobox.Input press.
packages/react/src/combobox/root/AriaCombobox.tsx Updates click/open reason mapping to differentiate input vs trigger press; needs verification that useClick reason defaults and popup-contained input handling are consistent across all open paths.
packages/react/src/floating-ui-react/hooks/useClick.ts Introduces optional configurable reason for click interactions (default triggerPress); potential bug if the same hook instance handles both reference and floating clicks—reason may be wrong for some paths without per-target override.
packages/react/src/utils/createBaseUIEventDetails.ts Extends reason-to-event-details mapping to include inputPress; appears straightforward.
packages/react/src/utils/reason-parts.ts Updates reason parsing/normalization to include inputPress; appears consistent with existing reason parts.

@pkg-pr-new

pkg-pr-new Bot commented Feb 8, 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@4015
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@4015
    

commit: bf002a0

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@greptile-apps

greptile-apps Bot commented Feb 8, 2026

Copy link
Copy Markdown
Contributor
Additional Comments (1)

packages/react/src/floating-ui-react/hooks/useClick.ts
Reason override applies globally
useClick now takes a single reason option, but the hook typically handles both reference clicks and floating clicks (e.g. click inside popup to toggle/close). With a single global reason, any floating click handled by the same hook instance will report the wrong onOpenChange reason (e.g. inputPress or triggerPress even when the click was in the popup), which breaks the intended “triggerPress when input inside popup” behavior described in the PR.

If the combobox needs different reasons depending on click target, useClick likely needs to derive the reason from event.currentTarget (reference vs floating) or accept separate referenceReason/floatingReason options rather than a single reason.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/react/src/floating-ui-react/hooks/useClick.ts
Line: 1:3

Comment:
**Reason override applies globally**
`useClick` now takes a single `reason` option, but the hook typically handles both reference clicks and floating clicks (e.g. click inside popup to toggle/close). With a single global `reason`, any floating click handled by the same hook instance will report the wrong `onOpenChange` reason (e.g. `inputPress` or `triggerPress` even when the click was in the popup), which breaks the intended “triggerPress when input inside popup” behavior described in the PR.

If the combobox needs different reasons depending on click target, `useClick` likely needs to derive the reason from `event.currentTarget` (reference vs floating) or accept separate `referenceReason`/`floatingReason` options rather than a single `reason`.

How can I resolve this? If you propose a fix, please make it concise.

@mui-bot

mui-bot commented Feb 8, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+38B(+0.01%) 🔺+24B(+0.02%)

Details of bundle changes


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

@netlify

netlify Bot commented Feb 8, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit bf002a0
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6989838b5cef9e000830d0cd
😎 Deploy Preview https://deploy-preview-4015--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.

@jijiseong
jijiseong requested a review from atomiks February 9, 2026 01:32
@atomiks atomiks added type: bug It doesn't behave as expected. component: combobox Changes related to the combobox component. labels Feb 9, 2026

@atomiks atomiks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix @jijiseong!

@atomiks
atomiks merged commit 4dd6aea into mui:master Feb 9, 2026
7 checks passed
@jijiseong
jijiseong deleted the feat/input-reason branch February 11, 2026 20:06
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. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[combobox] Separate trigger-press and input-press events

3 participants