Search filter: lazy-load option values - #233
Open
filipvnencak wants to merge 1 commit into
Open
filipvnencak wants to merge 1 commit into
filipvnencak wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Cache invalidation, boolean-option loading, exception handling, tooltip hydration, and accessibility issues remain.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds lazy-loaded SearchFilter option values with loading/error feedback and hydrated chip labels.
Changes:
- Adds
Option.loadValuesand lazy-value caching. - Updates filter-state creation and dropdown rendering.
- Adds a delayed lazy-loading Storybook example.
File summaries
| File | Description |
|---|---|
src/SearchFilter/types.ts |
Defines the lazy loader API. |
src/SearchFilter/SearchFilter.tsx |
Loads, merges, and displays lazy values. |
src/SearchFilter/SearchFilterDropdown/SearchFilterDropdown.tsx |
Shows loading and error states. |
src/SearchFilter/SearchFilterDropdown/SearchFilterDropdown.styled.ts |
Styles status messages. |
src/SearchFilter/SearchFilter.stories.tsx |
Demonstrates delayed loading. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 5
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| const options = useMemo(() => withLazyValues(rawOptions, lazyValues), [rawOptions, lazyValues]) | ||
|
|
||
| const loadOptionValues = (option?: Option) => { | ||
| if (!option?.loadValues || lazyRequestsRef.current.has(option.id)) return |
Comment on lines
+122
to
+126
| option | ||
| .loadValues() | ||
| .then((values) => | ||
| setLazyValues((current) => ({ ...current, [id]: { status: 'loaded', values } })), | ||
| ) |
| } = filterOption | ||
| const addFilter: Filter = { | ||
| ...filterOptionData, | ||
| const addFilter = createFilterState(filterOption, { |
| inverted={filter.inverted} | ||
| operator={filter.operator} | ||
| values={filter.values} | ||
| values={getDisplayValues(filter, option)} |
Comment on lines
+458
to
+459
| {valuesStatus === 'loading' && <Styled.Loading>Loading...</Styled.Loading>} | ||
| {valuesStatus === 'error' && <Styled.Loading>Could not load values</Styled.Loading>} |
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.
PR Checklist
Description of changes
Filter options can now load their values on first open, with a loading state in the dropdown.
Technical details
Option.loadValuesmerges fetched values into options; active filters load too so chips show labels (SearchFilter.tsx).createFilterStatekeeps option-only data out of filter state.LazyOptionsstory with a delayed palette filter.Additional context
Related to: ynput/ayon-frontend#2283