data-driven-forms / react-forms

React library for rendering forms.
https://data-driven-forms.org/
Apache License 2.0
295 stars 85 forks source link

Prevent isFetching bug in useSelect #1450

Closed haydenlinder closed 5 months ago

haydenlinder commented 5 months ago

Related to #1448

Description

When using searchable select with loadoOptions, the spinner persists after the promises have resolved.

The cause was this line returning true because there was an extra compareValues function in the reducer payloads.

I saved that function to another variable and removed it from the payload.

Schema (if applicable)

     {
              component: 'select',
              label: 'Select',
              name: 'select',
              options: [],
              isSearchable: true,
              loadOptions: () =>
                new Promise((res) =>
                  setTimeout(
                    () =>
                      res([
                        { value: 'first-option', label: 'First async option' },
                        { value: 'second-option', label: 'Second async option' },
                      ]),
                    2500
                  )
                ),
            },

Checklist: (please see documentation page for more information)

vercel[bot] commented 5 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-forms ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 21, 2024 8:54am
codecov[bot] commented 5 months ago

Codecov Report

Attention: Patch coverage is 66.66667% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 94.48%. Comparing base (271e466) to head (8edbfea).

Files Patch % Lines
packages/common/src/use-select/reducer.js 66.66% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1450 +/- ## ======================================= Coverage 94.48% 94.48% ======================================= Files 210 210 Lines 3971 3973 +2 Branches 1628 1628 ======================================= + Hits 3752 3754 +2 Misses 219 219 ```

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

haydenlinder commented 5 months ago

Closing in favor of https://github.com/data-driven-forms/react-forms/pull/1449

Hyperkid123 commented 5 months ago

Closing in favor of #1449

Ah. I see you found part of the problem as well. :)