Skip to content

[autocomplete] Backspace, Delete and the chip's own delete icon clear a single value rendered with renderValue despite disableClearable #49248

Closed

Description

@pcourant

Steps to reproduce

Steps:

  1. Open this link to live example: https://codesandbox.io/s/jy22jp (preview: https://jy22jp.csb.app/) (required)
  2. The Autocomplete is single-value, has disableClearable, and renders its value "René" as a chip through renderValue.
  3. Either: (a) click in the input then press Backspace, (b) click in the input then press Delete, or (c) click the chip's own delete (x) icon.

Current behavior

All three actions clear the value: onChange is called with null and reason "removeOption", and the chip disappears, although disableClearable is set.

Expected behavior

With disableClearable, none of these three actions clear the value: Backspace and Delete on an empty input, and the chip's own delete icon, all leave the single rendered value in place, as the hidden clear indicator already does, and as the input-clearing path already does.

Context

In useAutocomplete, three call sites remove the single renderValue value without reading disableClearable, while the input-clearing guard does:

Adding !disableClearable to these three conditions would align them with the input-clearing path. We render required single selects as chips, and currently guard Backspace/Delete ourselves with an onKeyDownCapture and hide the chip's delete icon with CSS; neither is needed once the library itself honors disableClearable here.

Your environment

npx @mui/envinfo
  Browsers: Chromium (via CodeSandbox preview)
  npmPackages:
    @mui/material: 9.4.0 (latest)
    react: latest
    react-dom: latest

Reproduced with both Backspace and Delete.

Search keywords: disableClearable renderValue backspace delete chip single handleSingleItemDelete

Activity

  1. ZeeshanTamboli commented on Sep 30, 2026

    @ZeeshanTamboli
    Member

    Thanks for reporting.

  2. added
    type: bugIt doesn't behave as expected.
    scope: autocompleteChanges related to the autocomplete. This includes ComboBox.
    and removed on Sep 30, 2026
  3. ZeeshanTamboli commented on Sep 30, 2026

    @ZeeshanTamboli
    Member

    disableClearable also doesn't work with multiple mode when using renderValue or without it: https://codesandbox.io/p/sandbox/mui-autocomplete-disableclearable-backspace-forked-qh8ndt. What do you think about this @pcourant ?

    I think disableClearable is meant to only remove the "Clear icon", but I don't think that works well in case of renderValue (single/multiple) and only multiple mode. It works only for single select mode.

  4. ZeeshanTamboli commented on Oct 1, 2026

    @ZeeshanTamboli
    Member

    @pcourant Also, does readOnly prop work for your use case?

  5. pcourant commented on Oct 1, 2026

    @pcourant
    Author

    readOnly doesn't fit: the field is required, not frozen. The user can pick another option, but must never leave it empty. readOnly keeps the popup closed (L246).

    Agreed on multiple: removing a chip is expected there, and I'm not asking to change it.

    Single value + renderValue still looks like a bug to me:

    So #49264, scoped to single-value renderValue, looks right to me.

  6. silviuaavram commented on Oct 5, 2026

    @silviuaavram
    Member

    Hi! I don't think this use case is valid. From the docs, disableClearable: If true, the input can't be cleared. And we're fulfilling that promise, we don't allow you to clear the input via the Clear button.

    What you're expecting is the value not being cleared. That's something else. Value, when using renderValue, in your case, has nothing to do with the input. It's not the input's value, it's another element (the chip), the input is empty whenever a value is selected and visible. Your use case sounds more like "whenever you pick a value, the most you can do is change it, you cannot unpick a value". And for this use case, you should be able to do it with our API. Just not with disableClearable which clearly has a different meaning and use case.

  7. github-actions commented on Oct 5, 2026

    @github-actions
    Contributor

    This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
    Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.


    @pcourant Thanks again for creating this issue! If you have a moment, we would love to hear your thoughts on how we handled it with this short feedback form.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope: autocompleteChanges related to the autocomplete. This includes ComboBox.type: expected behaviorThe current behavior is already the one expected.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions