Skip to content

[Autocomplete] Prevents Autocomplete menu from opening on right click#47797

Open
silviuaavram wants to merge 2 commits intomui:masterfrom
silviuaavram:fix/autocomplete-right-click
Open

[Autocomplete] Prevents Autocomplete menu from opening on right click#47797
silviuaavram wants to merge 2 commits intomui:masterfrom
silviuaavram:fix/autocomplete-right-click

Conversation

@silviuaavram
Copy link
Member

@silviuaavram silviuaavram commented Feb 17, 2026

It's basically #36389 from @taverasady but opened this one instead because of rebase/merge issues.

Fixes #36075

@mui-bot
Copy link

mui-bot commented Feb 17, 2026

Netlify deploy preview

Bundle size report

Bundle Parsed size Gzip size
@mui/material 🔺+14B(0.00%) 🔺+5B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against 61e718c

@silviuaavram silviuaavram added type: bug It doesn't behave as expected. breaking change Introduces changes that are not backward compatible. scope: autocomplete Changes related to the autocomplete. This includes ComboBox. v9.x labels Feb 17, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR prevents the Autocomplete menu from opening when the user right-clicks on the input field. It addresses issue #36075 by adding a check to ensure only left-click (button 0) triggers the popup indicator in the handleInputMouseDown handler.

Changes:

  • Added event.button === 0 check to handleInputMouseDown in useAutocomplete.js to filter out non-left clicks
  • Added a test case to verify right-click doesn't open the popup

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/mui-material/src/useAutocomplete/useAutocomplete.js Added button check to prevent right-click from opening the autocomplete popup
packages/mui-material/src/Autocomplete/Autocomplete.test.js Added test to verify right-click behavior

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@silviuaavram silviuaavram self-assigned this Feb 17, 2026
Copy link
Member

@ZeeshanTamboli ZeeshanTamboli left a comment

Choose a reason for hiding this comment

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

This works well but I think the input should also be focused when right-clicking on the border of the input like in Base UI Combobox: https://base-ui.com/react/components/combobox.

@silviuaavram
Copy link
Member Author

Are you sure? I right clicked everywhere, including on their border, and it's not opening. And it shouldn't.

@ZeeshanTamboli
Copy link
Member

ZeeshanTamboli commented Feb 18, 2026

and it's not opening.

I mean input should be focused on right click, and not the pop-up should be opened.

@silviuaavram
Copy link
Member Author

Oh I see. This is a different issue. We can fix it separately, since it doesn't seem to be a breaking change.

@ZeeshanTamboli
Copy link
Member

Oh I see. This is a different issue. We can fix it separately, since it doesn't seem to be a breaking change.

Alright.

Copy link
Member

@ZeeshanTamboli ZeeshanTamboli left a comment

Choose a reason for hiding this comment

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

Looks good to me.

Copy link
Member

@siriwatknp siriwatknp left a comment

Choose a reason for hiding this comment

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

Breaking change should be added to the upgrade-to-v9 page.

@silviuaavram silviuaavram force-pushed the fix/autocomplete-right-click branch from 95d728c to 61e718c Compare February 19, 2026 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Introduces changes that are not backward compatible. scope: autocomplete Changes related to the autocomplete. This includes ComboBox. type: bug It doesn't behave as expected. v9.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[material-ui] Autocomplete right click triggers open

4 participants

Comments