Skip to content

[select] Fix highlightItemOnHover not being respected#3868

Merged
LukasTy merged 1 commit into
mui:masterfrom
sarthakmalik0810:fix/select-to-respect-highlightItemOnHover
Jan 27, 2026
Merged

[select] Fix highlightItemOnHover not being respected#3868
LukasTy merged 1 commit into
mui:masterfrom
sarthakmalik0810:fix/select-to-respect-highlightItemOnHover

Conversation

@sarthakmalik0810

@sarthakmalik0810 sarthakmalik0810 commented Jan 26, 2026

Copy link
Copy Markdown
Contributor

When highlightItemOnHover is false, data-highlighted should not be applied to Select.Item's. Adding condition to onMouseEnter fixes it.

Unit tests did not fail as they were using fireEvent.mouseMove, UserEvent should trigger mouseEnter and mouseMove.

Fixes #3867

@mui-bot

mui-bot commented Jan 26, 2026

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+3B(0.00%) 🔺+3B(0.00%)

Details of bundle changes


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

@sarthakmalik0810 sarthakmalik0810 changed the title [select] Respect highlightItemOnHover false not being respected [select] Respect highlightItemOnHover false not being respected Jan 26, 2026
@greptile-apps

greptile-apps Bot commented Jan 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

Fixed highlightItemOnHover={false} not being respected on Select.Item components. The onMouseEnter handler was applying data-highlighted regardless of the highlightItemOnHover prop value.

  • Added highlightItemOnHover check to onMouseEnter handler in SelectItem.tsx:151, matching the existing pattern in onMouseMove and onMouseLeave
  • Updated tests to use user.hover() instead of fireEvent.mouseMove() to properly simulate user interactions and trigger both mouseEnter and mouseMove events

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The fix correctly addresses the bug by adding the missing highlightItemOnHover condition to the onMouseEnter handler, consistent with the existing pattern in onMouseMove and onMouseLeave. The test updates properly simulate user interactions using user.hover() instead of fireEvent.mouseMove(), which correctly triggers both mouseEnter and mouseMove events as would happen in real usage.
  • No files require special attention

Important Files Changed

Filename Overview
packages/react/src/select/item/SelectItem.tsx Added highlightItemOnHover check to onMouseEnter handler to properly respect the prop when false
packages/react/src/select/root/SelectRoot.test.tsx Updated tests to use user.hover() instead of fireEvent.mouseMove() to properly trigger both mouseEnter and mouseMove events

@netlify

netlify Bot commented Jan 26, 2026

Copy link
Copy Markdown

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 5ce9550
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6977b84f082782000939aba5
😎 Deploy Preview https://deploy-preview-3868--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.

@sarthakmalik0810 sarthakmalik0810 force-pushed the fix/select-to-respect-highlightItemOnHover branch from 950f581 to 244a189 Compare January 26, 2026 16:19
@sarthakmalik0810 sarthakmalik0810 changed the title [select] Respect highlightItemOnHover false not being respected [select] Fix highlightItemOnHover false not being respected Jan 26, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jan 26, 2026

Copy link
Copy Markdown

commit: 5ce9550

@sarthakmalik0810 sarthakmalik0810 force-pushed the fix/select-to-respect-highlightItemOnHover branch from 244a189 to a280a05 Compare January 26, 2026 16:21
@sarthakmalik0810 sarthakmalik0810 changed the title [select] Fix highlightItemOnHover false not being respected [select] Fix highlightItemOnHover not being respected Jan 26, 2026
@sarthakmalik0810 sarthakmalik0810 force-pushed the fix/select-to-respect-highlightItemOnHover branch from a280a05 to 5ce9550 Compare January 26, 2026 18:54
@LukasTy LukasTy added component: select Changes related to the select component. type: bug It doesn't behave as expected. labels Jan 27, 2026

@LukasTy LukasTy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice attention to detail. 👍
Thank you for fixing this issue. 🙏

@LukasTy LukasTy merged commit d4d3f4d into mui:master Jan 27, 2026
24 of 25 checks passed
atomiks pushed a commit to atomiks/base-ui that referenced this pull request Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[select] highlightItemOnHover not being respected

3 participants