Skip to content

[combobox] Keep highlight on last deselect - #3923

Merged
atomiks merged 1 commit into
mui:masterfrom
atomiks:atomiks/multi-combo-hl
Feb 6, 2026
Merged

atomiks merged 1 commit into
mui:masterfrom
atomiks:atomiks/multi-combo-hl

Conversation

@atomiks

@atomiks atomiks commented Feb 1, 2026

Copy link
Copy Markdown
Contributor

After typing, selecting, then re-opening and deselecting the last item, the active index would reset to null incorrectly

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

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

commit: eeff3c0

@mui-bot

mui-bot commented Feb 1, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react ▼-340B(-0.08%) ▼-4B(0.00%)

Details of bundle changes


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

@netlify

netlify Bot commented Feb 1, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit eeff3c0
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6985a4b88d6af60008a2cdaf
😎 Deploy Preview https://deploy-preview-3923--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 atomiks/multi-combo-hl branch from 32cf7b4 to 0601b23 Compare February 1, 2026 23:23
@atomiks
atomiks marked this pull request as ready for review February 1, 2026 23:49
@greptile-apps

greptile-apps Bot commented Feb 1, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

Changed the combobox to preserve activeIndex (highlight) when deselecting the last item in multiple mode. Previously, both activeIndex and selectedIndex were cleared when removing the final selection, causing the list highlight to disappear unexpectedly.

Key changes:

  • Modified setIndices calls throughout to only clear selectedIndex when deselecting items
  • Removed complex logic in ComboboxChipRemove that was attempting to detect and clear highlights for removed items
  • Simplified chip deletion handlers to only reset selectedIndex, allowing active highlight to persist
  • Added comprehensive tests verifying highlight retention after clearing the last selection

This ensures that when hovering/navigating to an item and then deselecting it (even if it's the last selected item), the visual highlight remains on that item, providing better UX consistency.

Confidence Score: 5/5

  • This PR is safe to merge - it fixes a UX bug with minimal risk
  • The changes are well-scoped and thoroughly tested with two new test cases. The simplification removes complex conditional logic and makes behavior more predictable. The fix correctly distinguishes between activeIndex (visual highlight) and selectedIndex (list navigation state), addressing the root cause.
  • No files require special attention

Important Files Changed

Filename Overview
packages/react/src/combobox/root/AriaCombobox.tsx Changed to preserve activeIndex when clearing last selection by only resetting selectedIndex
packages/react/src/combobox/input/ComboboxInput.tsx Updated all chip deletion logic to preserve activeIndex by only clearing selectedIndex
packages/react/src/combobox/chip-remove/ComboboxChipRemove.tsx Removed complex logic for clearing highlight when removing chips, simplifying the implementation

@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

@atomiks
atomiks force-pushed the atomiks/multi-combo-hl branch from 0601b23 to d6c7158 Compare February 2, 2026 00:30
@atomiks

atomiks commented Feb 2, 2026

Copy link
Copy Markdown
Contributor Author

@greptileai

@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Feb 5, 2026
@atomiks
atomiks force-pushed the atomiks/multi-combo-hl branch from 4c5b196 to 421ca97 Compare February 6, 2026 04:03
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Feb 6, 2026
@atomiks
atomiks force-pushed the atomiks/multi-combo-hl branch from 421ca97 to 00f43dc Compare February 6, 2026 07:33
@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Feb 6, 2026
@atomiks
atomiks force-pushed the atomiks/multi-combo-hl branch from a550506 to 842ec24 Compare February 6, 2026 07:37
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Feb 6, 2026
@atomiks
atomiks force-pushed the atomiks/multi-combo-hl branch 3 times, most recently from 9aa0ad0 to 03fe57a Compare February 6, 2026 07:59
@atomiks
atomiks force-pushed the atomiks/multi-combo-hl branch from 03fe57a to eeff3c0 Compare February 6, 2026 08:22
@atomiks
atomiks merged commit 4b98338 into mui:master Feb 6, 2026
7 checks passed
@atomiks
atomiks deleted the atomiks/multi-combo-hl branch February 6, 2026 08:26
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.

3 participants