Repository navigation
Conversation
useSearchableListState rebuilt the unfiltered results and re-ran fuzzysort.prepare for every item on each search change. Memoize those on the item list and filter against a deferred search string so typing stays responsive with large lists (e.g. Select Project on large installs). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: Shawn Sun <shasun@linkedin.com>
Author
|
Friendly ping @Sovietaced @pingsutw, could you take a look when you have a moment? CI is green and it merges cleanly. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
useSearchableListStaterebuilt its unfiltered results and calledfuzzysort.prepareon every item on every keystroke, because both happened inside theuseMemokeyed onsearchString. On installs with many projects, workflows or launch plans, this makes search inputs (e.g. Select Project, which #941 paginated) lag while typing.Changes
unfilteredResultsand the prepared fuzzysort items on[items, propertyGetter], so they are computed once per item list instead of once per keystroke.useDeferredValue(searchString)so the input stays responsive while results update.loadingis nowtruewhile the deferred search value catches up; it used to be alwaysfalse. No current caller readsloading.common/test/useSearchableListState.test.tsx, covering empty search, filtering, and thatfuzzysort.prepareruns once per item and not again on each keystroke.All current callers (
SelectProject,FilterableNamedEntityList,ResponsiveLaunchPlanList) pass string property getters, so the memo stays stable across renders.Testing
NODE_ENV=test yarn jest packages/oss-console/src/components/common packages/oss-console/src/components/SelectProject packages/oss-console/src/components/LaunchPlan→ 8 suites / 21 tests passednpx eslinton the changed files → no issuesAll commits are signed off (DCO).