Skip to content

fix(virtual_scroll): prevent preloaded options from bleeding into search results#1042

Open
HSAIG wants to merge 1 commit into
orchidjs:masterfrom
HSAIG:fix/virtual-scroll-preloaded-options-bleeding-into-search
Open

fix(virtual_scroll): prevent preloaded options from bleeding into search results#1042
HSAIG wants to merge 1 commit into
orchidjs:masterfrom
HSAIG:fix/virtual-scroll-preloaded-options-bleeding-into-search

Conversation

@HSAIG
Copy link
Copy Markdown

@HSAIG HSAIG commented May 22, 2026

Problem

#1039

When using virtual_scroll with preload: true, the options loaded on the initial empty query were kept in self.options during subsequent searches.
This caused preloaded options to appear alongside (or instead of) the actual search results.

Root cause

In loadCallback, clearOptions(clearFilter) was always called, which preserves any option present in default_values ? including remotely preloaded ones. Those options would then show up in the dropdown during search.

Solution

  • During search (non-empty query): clear preloaded remote options, keeping only selected items and static HTML options (html_values).
  • On search clear: re-add the preloaded option objects via addOptions() before calling clearOptions(), since clearOptions can only remove existing options ? it cannot restore ones that were already cleared.

Two new variables are introduced:

  • html_values: keys of options present in the HTML markup at initialize time, which must always survive the search filter.
  • default_options: the actual option objects captured after the initial preload, used to restore the dropdown when search is cleared.

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.

1 participant