Repository navigation
perf(explore): use useDeferredValue for datasource panel search - #39970
Conversation
Replace useDebounceValue (FAST_DEBOUNCE-delayed) with React 18's useDeferredValue in the datasource panel's column/metric search. Refs #39890. Same rationale as #39928: the input field reads inputValue directly so typing stays responsive, while matchSorter reads searchKeyword (now deferred). React schedules the filter as low-priority work and interrupts it on each keystroke, so there's no fixed delay holding the deferred value behind. Drop the no-longer-needed Constants import. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Code Review Agent Run #7626c3Actionable Suggestions - 0Additional Suggestions - 2
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
Updates the Explore Datasource Panel’s column/metric search to use React 18’s useDeferredValue instead of a fixed-delay debounce, keeping the input responsive while deferring the expensive client-side filtering work.
Changes:
- Replaced
useDebounceValue(inputValue, Constants.FAST_DEBOUNCE)withuseDeferredValue(inputValue)for the datasource search keyword. - Removed the now-unused
ConstantsanduseDebounceValueimports.
…he#39970) Co-authored-by: Claude Code <[email protected]>
Refs apache#39890. Continues the useDeferredValue adoption (apache#39928, apache#39970, apache#44878) for the two lodash debounce() sites in the native Select filter plugin. Two debounces here, both converted: - `onSearch`: client-side option filtering now reads `deferredSearchInput` directly (a pure render-value case, same shape as the earlier PRs). The conditional `searchAllOptions` server-side dispatch is a genuine side effect, so it moved into an effect keyed on the deferred value, guarded by `hasSearchedRef` so it never fires on mount or as a result of the clearAllTrigger reset (which must stay silent, matching the prior debounce-based behavior exactly). - `debouncedLikeChange` (the LIKE/Contains/StartsWith/EndsWith text input): same shape as TextControl's (apache#44878) pendingValue pattern. `isLikeOperator`/`clearAllTrigger` are read live in the effect instead of via an explicit `.cancel()`, since there's no longer a pending timer to cancel; the guard itself does the same job. Both effects read mutable state (searchAllOptions/dispatchDataMask/ initialColtypeMap, and updateDataMask) through refs so a parent re-render handing down fresh identities doesn't itself re-fire them. Test changes: the LIKE-debounce test suite used `jest.useFakeTimers()` + `jest.advanceTimersByTime()` to force the old debounce to fire. useDeferredValue has no literal timer to advance (it settles via React's own scheduler, independent of fake timers), so the "pending debounce survives a rerender" and "...is canceled on operator switch" tests needed restructuring: the keystroke and the rerender now batch into one `act()` so the deferred value hasn't settled before the identity change, which is what actually exercises the stale-ref path useDeferredValue's much-faster settling had stopped being able to simulate via timer advancement alone. `keeps "Select all" pinned to the full column while searching (creatable false)` fails identically on unmodified origin/master (confirmed in an isolated worktree) -- a pre-existing environment flake unrelated to this change, left as-is. Pre-commit's Type-Checking (Frontend) hook is skipped: it type-checks against this worktree's symlinked packages/*/lib build output, which doesn't match this source tree and throws unrelated pre-existing errors in files this commit doesn't touch. Verified independently: `npx tsc --noEmit -p tsconfig.json` reports zero errors in the changed files, `npx oxlint`/`npx oxfmt --check` are clean, and 47/48 tests in SelectFilterPlugin.test.tsx pass (the one pre-existing failure noted above). Co-Authored-By: Evan Rusackas <[email protected]> Co-Authored-By: Claude Sonnet 5 <[email protected]>
Refs apache#39890. Replaces the lodash debounce() wrapping TextControl's onChange propagation with useDeferredValue, following the pattern already landed for TableExploreTree (apache#39928) and DatasourcePanel (apache#39970). The debounce only gated when the parsed value reached the parent via onChange; the input itself (localValue) was already updated synchronously. useDeferredValue gives the same batching without a fixed timer: the deferred value is low-priority and gets interrupted by each new keystroke, so a burst of typing doesn't leave a stale onChange call trailing behind it. Kept `pendingValue` separate from `localValue`/`displayValue`: the sync branch that mirrors an externally-changed `value` prop into `localValue` must never itself trigger onChange, only an actual keystroke should. `handleChange` is read through a ref inside the effect so a parent re-render that hands down a fresh `onChange` identity (common across control-panel controls) doesn't re-fire it on its own, pinned by the new "new onChange identity" test. Pre-commit's Type-Checking (Frontend) hook is skipped: it type-checks against this worktree's symlinked packages/*/lib build output, which doesn't match this source tree and throws unrelated pre-existing errors in files this commit doesn't touch. Verified independently: `npx tsc --noEmit -p tsconfig.json` reports zero errors in the changed files, `npx oxlint`/`npx oxfmt --check` are clean, and all 11 tests in TextControl.test.tsx pass. Co-Authored-By: Evan Rusackas <[email protected]> Co-Authored-By: Claude Sonnet 5 <[email protected]>
Refs apache#39890. Replaces the lodash debounce() wrapping TextControl's onChange propagation with useDeferredValue, following the pattern already landed for TableExploreTree (apache#39928) and DatasourcePanel (apache#39970). The debounce only gated when the parsed value reached the parent via onChange; the input itself (localValue) was already updated synchronously. useDeferredValue gives the same batching without a fixed timer: the deferred value is low-priority and gets interrupted by each new keystroke, so a burst of typing doesn't leave a stale onChange call trailing behind it. Kept `pendingValue` separate from `localValue`/`displayValue`: the sync branch that mirrors an externally-changed `value` prop into `localValue` must never itself trigger onChange, only an actual keystroke should. `handleChange` is read through a ref inside the effect so a parent re-render that hands down a fresh `onChange` identity (common across control-panel controls) doesn't re-fire it on its own, pinned by the new "new onChange identity" test. Pre-commit's Type-Checking (Frontend) hook is skipped: it type-checks against this worktree's symlinked packages/*/lib build output, which doesn't match this source tree and throws unrelated pre-existing errors in files this commit doesn't touch. Verified independently: `npx tsc --noEmit -p tsconfig.json` reports zero errors in the changed files, `npx oxlint`/`npx oxfmt --check` are clean, and all 11 tests in TextControl.test.tsx pass. Co-Authored-By: Evan Rusackas <[email protected]> Co-Authored-By: Claude Sonnet 5 <[email protected]>
Refs apache#39890. Replaces the lodash debounce() wrapping TextControl's onChange propagation with useDeferredValue, following the pattern already landed for TableExploreTree (apache#39928) and DatasourcePanel (apache#39970). The debounce only gated when the parsed value reached the parent via onChange; the input itself (localValue) was already updated synchronously. useDeferredValue gives the same batching without a fixed timer: the deferred value is low-priority and gets interrupted by each new keystroke, so a burst of typing doesn't leave a stale onChange call trailing behind it. Kept `pendingValue` separate from `localValue`/`displayValue`: the sync branch that mirrors an externally-changed `value` prop into `localValue` must never itself trigger onChange, only an actual keystroke should. `handleChange` is read through a ref inside the effect so a parent re-render that hands down a fresh `onChange` identity (common across control-panel controls) doesn't re-fire it on its own, pinned by the new "new onChange identity" test. Pre-commit's Type-Checking (Frontend) hook is skipped: it type-checks against this worktree's symlinked packages/*/lib build output, which doesn't match this source tree and throws unrelated pre-existing errors in files this commit doesn't touch. Verified independently: `npx tsc --noEmit -p tsconfig.json` reports zero errors in the changed files, `npx oxlint`/`npx oxfmt --check` are clean, and all 11 tests in TextControl.test.tsx pass. Co-Authored-By: Evan Rusackas <[email protected]> Co-Authored-By: Claude Sonnet 5 <[email protected]>
SUMMARY
Refs #39890. Second
useDeferredValueadoption (after #39928). Replaces the fixed-delayuseDebounceValuewithuseDeferredValuein the explore Datasource Panel's column/metric search box.Why useDeferredValue is the right fit here
Same UI-filter pattern as #39928's TableExploreTree migration:
inputValuedirectly (kept responsive on every keystroke).matchSorterreadssearchKeyword, now derived viauseDeferredValue.FAST_DEBOUNCEwindow holding the filtered list behind the input.The
Constantsimport (only used forFAST_DEBOUNCE) is dropped.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
No visual change. Behaviorally: column/metric search in the explore datasource panel should feel snappier — typing never lags behind because the filter is no longer waiting on a debounce window before recomputing.
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION