Skip to content

[combobox] Fix Chips area clicks not focusing input or opening popup - #4296

Merged
atomiks merged 9 commits into
mui:masterfrom
CiscoFran10:fix/combobox-chips-padding-click
Mar 19, 2026
Merged

atomiks merged 9 commits into
mui:masterfrom
CiscoFran10:fix/combobox-chips-padding-click

Conversation

@CiscoFran10

Copy link
Copy Markdown
Contributor

Clicking anywhere in the <Combobox.Chips> container (padding or a chip) now focuses the input and opens the popup when openOnInputClick is true, matching the behavior of clicking the input. Demos that use Chips use cursor: text on the container so the area looks and behaves like an input.

Closes #4289.


Current behavior (before fix):

  • Clicking the padding of the Chips container did nothing: the input did not receive focus.
  • Clicking a chip focused the input only because each chip had its own onMouseDown; the container had no handler.
  • The popup did not open when clicking padding or chip, because Floating UI’s useClick is bound to the reference (the input). Clicks on Chips never hit that reference.

Changes:

  • ComboboxChips.tsx

    • Subscribe to store: disabled, readOnly, openOnInputClick.
    • Add an onMouseDown handler on the container that:
      • Returns when readOnly.
      • Calls event.preventDefault() then returns when disabled.
      • Otherwise: focuses the input via store.state.inputRef.current?.focus(), then, if openOnInputClick, calls store.state.setOpen(true, createChangeEventDetails(REASONS.inputPress, event.nativeEvent)).
      • Invokes elementProps.onMouseDown?.(event) so consumer handlers still run.
  • ComboboxChip.tsx

    • Remove the per-chip onMouseDown (focus input).
    • Clicks on a chip bubble to the container; the container’s handler now does focus + open. No duplicated logic.
  • ComboboxChips.test.tsx

    • “focuses the input when clicking anywhere in the Chips area”: fireEvent.mouseDown(chips) then fireEvent.mouseDown(chip).

@pkg-pr-new

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

commit: cc0b179

@mui-bot

mui-bot commented Mar 11, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+354B(+0.08%) 🔺+81B(+0.06%)

Details of bundle changes


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

@netlify

netlify Bot commented Mar 11, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit cc0b179
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/69bb3f16ae49b400090ff189
😎 Deploy Preview https://deploy-preview-4296--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.

@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Mar 11, 2026
@zannager zannager added the component: combobox Changes related to the combobox component. label Mar 11, 2026
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Mar 12, 2026
@atomiks

atomiks commented Mar 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review

Overview

This branch makes combobox chips and input-group padding clicks behave more like direct input clicks, so clicking the styled container focuses the input and can open the popup. It also keeps chip-remove presses from collapsing that flow, reuses the shared interactive-element helper in hover logic, and updates the demos to match the new interaction surface.

Findings

1. ℹ️ [Informational] Add a hover regression around links after the shared selector change

Impact: The hover refactor now routes both hover paths through a single interactive-element selector, so future link-related regressions will be harder to catch until that new behavior is pinned by a focused test.

Evidence: packages/react/src/floating-ui-react/hooks/useHover.ts now imports the shared isInteractiveElement, packages/react/src/floating-ui-react/hooks/useHoverInteractionSharedState.ts re-exports that same helper, and packages/react/src/floating-ui-react/utils/element.ts defines the new shared selector with a[href]. The touched packages/react/src/floating-ui-react/hooks/useHover.test.tsx coverage still mounts only a <button> reference and does not add a link-specific regression.

Recommendation: Add a focused useHover regression that exercises an anchor-based interactive target so the new shared selector behavior is explicitly covered.

No blocking issues found in this patch.

Confidence: 4/5

High confidence based on a full master...HEAD pass of the current branch, plus parallel category sweeps for React correctness, accessibility, API/state design, maintainability, performance, and test quality. The remaining risk is low and mostly limited to unpinned edge-case coverage rather than a concrete logic defect.

Notes

  • Focused verification run on this branch included pnpm test:jsdom ComboboxChips --no-watch, pnpm test:jsdom ComboboxInputGroup --no-watch, pnpm test:jsdom ComboboxChipRemove --no-watch, pnpm test:jsdom useHover --no-watch, pnpm test:chromium ComboboxChips --no-watch, pnpm test:chromium ComboboxInputGroup --no-watch, and pnpm test:chromium ComboboxChipRemove --no-watch.
  • I did not run a dedicated benchmark because this diff does not introduce a plausible hot-path performance regression.

@atomiks

atomiks commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

With the new InputGroup part, the padding styles changed a bit, so clicking the padding area still doesn't work here

@atomiks
atomiks force-pushed the fix/combobox-chips-padding-click branch 6 times, most recently from 2c3f1b5 to 6c5164d Compare March 12, 2026 05:45
@github-actions github-actions Bot added PR: out-of-date The pull request has merge conflicts and can't be merged. and removed PR: out-of-date The pull request has merge conflicts and can't be merged. labels Mar 16, 2026
@atomiks
atomiks force-pushed the fix/combobox-chips-padding-click branch from 6c58ab3 to 6cbb546 Compare March 18, 2026 15:41
@atomiks atomiks added the type: bug It doesn't behave as expected. label Mar 18, 2026
@atomiks
atomiks merged commit 3083313 into mui:master Mar 19, 2026
7 checks passed
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][docs] Multiple selection combobox examples ignores mouse clicks in padding area

4 participants