Skip to content

Conversation

@jnbain
Copy link

@jnbain jnbain commented Dec 3, 2025

Fixes #47241


Checklist

  • The branch is targeted at master
  • I have tested the changes locally
  • The code follows the project's coding style (prettier applied)
  • Tests added/updated (guidance needed - this is my first PR to Material-UI)

Previews:

- Only select chip/value when cursor is at start of input (position 0)
- Makes multiple mode consistent with single mode behavior
- Fixes mui#47241
@mui-bot
Copy link

mui-bot commented Dec 3, 2025

Netlify deploy preview

https://deploy-preview-47411--material-ui.netlify.app/

Bundle size report

Bundle Parsed size Gzip size
@mui/material 🔺+199B(+0.04%) 🔺+57B(+0.04%)
@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 60afc1f

@mj12albert
Copy link
Member

Single mode: Pressing ArrowLeft selects the value even when the input field contains text
Multiple mode: Pressing ArrowLeft does nothing when the input field contains text

TBH I don't really understand this, do you press ArrowLeft when the input is already focused? Would appreciate a screen recording if possible

@zannager zannager added the scope: autocomplete Changes related to the autocomplete. This includes ComboBox. label Dec 3, 2025
@ZeeshanTamboli
Copy link
Member

ZeeshanTamboli commented Dec 4, 2025

Single mode: Pressing ArrowLeft selects the value even when the input field contains text
Multiple mode: Pressing ArrowLeft does nothing when the input field contains text

TBH I don't really understand this, do you press ArrowLeft when the input is already focused? Would appreciate a screen recording if possible

@mj12albert Yes, it happens when the input is focused. By “value,” the author meant the selected value Chip. The behavior in the fix matches Base UI Combobox: https://base-ui.com/react/components/combobox#multiple-select (which I suppose is ARIA compliant).

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.

@jnbain Thanks for the PR. Some existing tests are failing that can be checked in CI.

@ZeeshanTamboli ZeeshanTamboli added the type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. label Dec 4, 2025
@mj12albert
Copy link
Member

I think the change is fine, though I don't think this behavior is specified in ARIA

Single mode: Pressing ArrowLeft selects the value even when the input field contains text

The issue is this, assuming it's referring to https://mui.com/material-ui/react-autocomplete/#single-value-rendering

The behavior seems buggy as you can't move the caret through the whole text, it just jumps from the end to the chip

So I suppose it's not that the behaviors are inconsistent between single/multiple but they each have their individual bugs

@ZeeshanTamboli ZeeshanTamboli changed the title [material-ui][Autocomplete] Fix ArrowLeft behavior in multiple mode with input text [autocomplete] Fix ArrowLeft behavior in multiple mode with input text Dec 4, 2025
@ZeeshanTamboli ZeeshanTamboli changed the title [autocomplete] Fix ArrowLeft behavior in multiple mode with input text [autocomplete] Fix <kbd>ArrowLeft</kbd> behavior in multiple mode with input text Dec 4, 2025
@ZeeshanTamboli ZeeshanTamboli changed the title [autocomplete] Fix <kbd>ArrowLeft</kbd> behavior in multiple mode with input text [autocomplete] Fix ArrowLeft behavior in multiple mode with input text Dec 4, 2025
@ZeeshanTamboli ZeeshanTamboli changed the title [autocomplete] Fix ArrowLeft behavior in multiple mode with input text [autocomplete] Fix ArrowLeft behavior in multiple and single value rendering mode with input text Dec 5, 2025
@ZeeshanTamboli ZeeshanTamboli changed the title [autocomplete] Fix ArrowLeft behavior in multiple and single value rendering mode with input text [autocomplete] Fix ArrowLeft, Backspace and Delete behavior in multiple and single value rendering mode with input text Dec 5, 2025
@ZeeshanTamboli ZeeshanTamboli added type: bug It doesn't behave as expected. and removed type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. labels Dec 6, 2025
@ZeeshanTamboli ZeeshanTamboli changed the title [autocomplete] Fix ArrowLeft, Backspace and Delete behavior in multiple and single value rendering mode with input text [autocomplete] Fix ArrowLeft, Backspace & Delete behavior for multiple and single-value rendering with proper caret handling Dec 8, 2025
@ZeeshanTamboli
Copy link
Member

@jnbain Made the expected changes, including fixes for Backspace and Delete. I have also added tests. @mj12albert would you mind reviewing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: autocomplete Changes related to the autocomplete. This includes ComboBox. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[autocomplete] Inconsistent behavior between single and multiple rendered values

5 participants