adevinta / spark

✨ Simple, Modular & Accessible UI Components for your React Applications
https://sparkui.vercel.app
MIT License
51 stars 16 forks source link

fix(combobox): onValueChange was triggered even when selected item ha… #2187

Closed Powerplex closed 1 month ago

Powerplex commented 1 month ago

Description, Motivation and Context

In the singleSelectionReducer, when blur event is triggered or disclosureButton is clicked, it calls setSelectedItem to reset it, which in return triggers onValueChange prop (callback).

I added an optimization to check that the selected item (or none item selected) has changed before triggering the callback, which was called too many times.

Types of changes

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 97.63%. Comparing base (917e9ce) to head (30d9012). Report is 8 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #2187 +/- ## ======================================= Coverage 97.63% 97.63% ======================================= Files 749 749 Lines 5880 5885 +5 Branches 2074 2076 +2 ======================================= + Hits 5741 5746 +5 Misses 137 137 Partials 2 2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.