designsystemet icon indicating copy to clipboard operation
designsystemet copied to clipboard

Combobox - Cannot reset controlled combobox

Open sharizard opened this issue 6 months ago • 9 comments

Description of the bug

I extended the controlled combobox example (codeexample from here) with a new button: Nullstill.

The button is quite simple, and sets the value of the combobox to an empty array.

      <Button
        onClick={() => {
          setValue([])
        }}
        style={{ marginBottom: '1rem' }}
      >
        Nullstill
      </Button>

I expect the combobox to be reset when clicking on the button, just as when the user clicks on the clear button.

However, the combobox does not get fully reset. The options are gone, but the value is still present in the input field.

See the video for an example.

https://github.com/user-attachments/assets/fe53fc0d-f2ca-4ded-8857-aa5e337a7af9

Steps To Reproduce

  1. Extend the "Controlled combobox storybook example" with a new button: Reset
  2. Update value to an empty array in Reset buttons onClick handler

Additional Information

No response

sharizard avatar Aug 15 '24 10:08 sharizard