fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

[Feature]: Enhance clearable feature in Combobox and Dropdown: Using the clearButton should fire the onChange event

Open sven-pohl opened this issue 1 year ago • 1 comments

Library

React Components / v9 (@fluentui/react-components)

Describe the feature that you would like added

Currently clicking the clearButton just sets the selectedOptions to an empty array but does not fire the onChange event. Our understanding is, that clearing the selectedOptions property and therefore also setting the value of the component to undefined is a change of the state of the component. Forms need to be informed of this change to properly handle the state of the form (isDirty flags, etc.). This is usually done by firing the "onChange" event.

Have you discussed this feature with our team

No response

Additional context

In our current project we use react-hook-form together with FluentUI react-components. Clearing comboboxes or dropdowns is not recognized as change of the components because the onChange event is nor fired. Unfortunately also no other event is fired so we are not able to mitigate this missing behaviour.

Validations

  • [X] Check that there isn't already an issue that requests the same feature to avoid creating a duplicate.

Priority

High

sven-pohl avatar Aug 27 '24 08:08 sven-pohl

thoughts on this @smhigley @ling1726 ?

Hotell avatar Aug 27 '24 16:08 Hotell

The correct callback to listen to updates for clearable combobox is onOptionSelecthttps://stackblitz.com/edit/axguq8?file=src%2Fexample.tsx.

The clearable combobox does not support freeform or multiselect currently

ling1726 avatar Sep 23 '24 14:09 ling1726

Not intuitive and per definition a bad DevX. But at least it works. Thanks, Sven

sven-pohl avatar Sep 23 '24 14:09 sven-pohl