Skip to content

Search filter: lazy-load option values - #233

Open
filipvnencak wants to merge 1 commit into
developfrom
2243-searchfilter-lazy-options
Open

filipvnencak wants to merge 1 commit into
developfrom
2243-searchfilter-lazy-options

Conversation

@filipvnencak

@filipvnencak filipvnencak commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

PR Checklist

  • This comment contains a description of changes
  • Referenced issue is linked

Description of changes

Filter options can now load their values on first open, with a loading state in the dropdown.

Technical details

  • New Option.loadValues merges fetched values into options; active filters load too so chips show labels (SearchFilter.tsx).
  • createFilterState keeps option-only data out of filter state.
  • New LazyOptions story with a delayed palette filter.

Additional context

Related to: ynput/ayon-frontend#2283

@filipvnencak filipvnencak changed the title feat(SF): implement lazy loading for filter option values in SearchFi… Search filter: lazy-load option values Sep 14, 2026
@filipvnencak
filipvnencak requested a balanced review from Copilot September 14, 2026 15:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.loadValues and 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>}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants