rusackas opened a new pull request, #44880:
URL: https://github.com/apache/superset/pull/44880
### SUMMARY
Refs #39890. Continues the `useDeferredValue` adoption started in #39928
(`TableExploreTree`), #39970 (`DatasourcePanel`), and #44878 (`TextControl`),
this time for the native `Select` dashboard filter plugin, which has two
separate `lodash` `debounce()` sites.
### Two debounces, two shapes
- **`onSearch`** — client-side option filtering. This is a pure render-value
case, the same shape as `TableExploreTree`/`DatasourcePanel`: the dropdown's
options list now reads `deferredSearchInput` directly. There's also a
conditional `searchAllOptions` dispatch (asking the server to search the whole
column), which is a genuine side effect, so it moved into an effect keyed on
the deferred value, guarded so it never fires on mount or as a side effect of
the "Clear All" reset (both silent in the original debounce-based code too).
- **`debouncedLikeChange`** — the free-text input for the
LIKE/Contains/StartsWith/EndsWith operators. Same shape as `TextControl`'s
(#44878) `pendingValue` pattern: the debounce only ever gated when the
committed value reached `updateDataMask`, so it became a `pendingLikeValue`
state + effect, same as `TextControl`.
Both effects read their mutable dependencies
(`searchAllOptions`/`dispatchDataMask`/`initialColtypeMap`, and
`updateDataMask`) through refs, so a parent re-render handing down fresh
identities for any of them doesn't itself re-fire the effect, only an actual
change to the deferred value should.
### A test-infrastructure wrinkle worth flagging explicitly
The LIKE-debounce tests 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, and settles much faster in a flushed
test environment than a real debounce window would. Two tests ("pending LIKE
debounce still applies after rerender recreates updateDataMask", "...is
canceled when operatorType switches back to Exact") 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. Without that batching, the old test shape raced against a
window that no longer exists, since `useDeferredValue` settles immediately once
nothing else is competing for render priority.
`keeps "Select all" pinned to the full column while searching (creatable
false)` fails identically on an unmodified `master` checkout (confirmed in an
isolated worktree before touching anything), it's a pre-existing environment
flake unrelated to this change and is left as-is.
### TESTING INSTRUCTIONS
1. Add a native Select filter to a dashboard, type into its search box
rapidly. Input stays responsive, option list narrows shortly after.
2. With "Search all filter's options" enabled on the filter, confirm a
server-side search still fires (and only once settled, not per keystroke).
3. Switch the filter's operator to "contains"/"starts with"/"ends with" and
type into the free-text input; confirm the filter still applies shortly after
typing stops.
4. "Clear All" on a dashboard with an active search/LIKE value should reset
cleanly with no stale dispatch.
5. `npm test -- --testPathPatterns='SelectFilterPlugin'` — 47/48 passing
locally (1 pre-existing, unrelated flake, see above).
### ADDITIONAL INFORMATION
- [x] Has associated issue: #39890
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]