microsoft / fluentui

Fluent UI web represents a collection of utilities, React components, and web components for building web applications.
https://react.fluentui.dev
Other
18.31k stars 2.71k forks source link

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

Open sven-pohl opened 2 weeks ago

sven-pohl commented 2 weeks ago

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. Therefore, the forms state isDirty and dirtyFields are not set. Unfortunately also no other event is fired so we are not able to mitigate this missing behaviour.

Validations

Priority

High

Hotell commented 2 weeks ago

thoughts on this @smhigley @ling1726 ?