Skip to content

[Feature Request] Clear v-autocomplete selection as soon as the text field is empty #5917

Closed

Description

@AlexandruMiricioiu

Problem to solve

v-autocomplete behavior after you choose an item:

Case 1: If you delete all the text then you tab out, the v-autocomplete selection reappears.
Case 2: If you delete all the text then you hit 'backspace' or 'delete' (just once) and then you tab out, you will be left with an v-autocomplete with selected text that display's nothing.
Case 3: If you delete all the text then you hit 'backspace' or 'delete' (twice), the selection disappears.

https://codepen.io/alexandrumiricioiu/pen/RERwYm
I don't know if this is a bug or not.

It will be nice if as soon as the text field is empty, the selection dissapears.
This will inprove the ux and avoid having empty v-autocompletes with data binded.

Proposed solution

I attached my workaround.
https://codepen.io/alexandrumiricioiu/pen/jXrOoB

Thank you

Activity

  1. KaelWD commented on Dec 18, 2018

    @KaelWD
    Member

    Case 3: If you delete all the text then you hit 'backspace' or 'delete' (twice), the selection disappears.

    This sounds like #4940

  2. Anima-t3d commented on Sep 3, 2019

    @Anima-t3d
  3. KaelWD commented on Sep 4, 2019

    @KaelWD
  4. added this to the v2.6.0 milestone on Oct 11, 2021
  5. added a commit that references this issue on Oct 11, 2021
    57d3469
  6. scscgit commented on Apr 12, 2022

    @scscgit
    Contributor

    Isn't the proposed solution still extremely dangerous for purposes of any forms where mistakes can have severe consequences? I strongly disagree with the default behavior of value de-selecting only after the input has been completely cleared. At the very least, this could be a parametrized behavior where we can choose if we want to clear the value on any change, even if the user only deletes a single character. As an extreme case, even if the user types the exact match, their input will still revert back to the previous & hidden internal value, which they may not notice.

    image

    I'm also tracking this, along with a related limitation of being unable to use a workaround, at

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

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions