Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] SingleSelect & MultiSelect: Add onChangeWithoutDebounce() #824

Merged
merged 3 commits into from
Feb 16, 2024

Conversation

riitasointi
Copy link
Collaborator

Description

This PR adds a new prop called onChangeWithoutDebounce() to <SingleSelect> & <MultiSelect>. The prop is basically the same as onChange() but does not use the debounce time even if it is specified.

Its inteded use case is mainly enabling the loading state of the component. It makes sense to show the loading spinner immediately when the user starts filtering and only make a backend call after a certain debounce time.

In addition, this PR also fixes an oversight in the SingleSelect component getDerivedStateFromProps() logic. Previously, when the value of the items prop or the selectedItem prop changed, the filter input's value was always set to an empty string ''. Now it only does that if selectedItem is set to null.

Motivation and Context

It was reported by users that having the loading state of the component only be applied after the debounce time is not ideal. It causes the existing items to be filtered briefly by the new input before the loading process begins.

How Has This Been Tested?

Styleguidist on Chrome & library's programmatic tests

Release notes

SingleSelect

  • Fix filter input value parsing when items or selectedItem prop changes
  • Add onChangeWithoutDebounce() prop. Inteded to be used to set the loadingprop

MultiSelect

  • Add onChangeWithoutDebounce() prop. Inteded to be used to set the loadingprop

@riitasointi riitasointi requested a review from LJKaski as a code owner January 21, 2024 16:56
@riitasointi riitasointi force-pushed the fix/select-loading-state-async branch from c1db3af to d1ec9c7 Compare February 8, 2024 10:53
@riitasointi riitasointi force-pushed the fix/select-loading-state-async branch from 4aec4e8 to 35baad6 Compare February 15, 2024 10:27
@riitasointi riitasointi merged commit 4493355 into develop Feb 16, 2024
1 check passed
@riitasointi riitasointi deleted the fix/select-loading-state-async branch February 16, 2024 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants