Skip to content

Fix(plugin/virtual_scroll): allow resetting preloaded default options via clearDefaultOptions - #1090

Open
dee-ene-gee wants to merge 1 commit into
orchidjs:masterfrom
dee-ene-gee:fix/virtual-scroll-reset-defaults
Open

dee-ene-gee wants to merge 1 commit into
orchidjs:masterfrom
dee-ene-gee:fix/virtual-scroll-reset-defaults

Conversation

@dee-ene-gee

Copy link
Copy Markdown

Summary of Changes

This PR addresses an issue where the virtual_scroll plugin permanently caches the initial empty-query preloaded options inside private closure variables (default_values, default_options, default_pagination, default_values_loaded).

When an external dynamic filter or URL parameter changes firstUrl, closing the dropdown or clearing a search (query === '') causes restoreDefaults() to reload the stale original options.

This PR adds a clearDefaultOptions() method to the TomSelect instance when using virtual_scroll, allowing developers to reset the cached default state when underlying filter context changes.


What Changed?

  • Exposed self.clearDefaultOptions() on the instance within virtual_scroll.ts.
  • Reset default_values, default_options, default_pagination, default_values_loaded, and called clearPagination() inside the method.
  • Added a unit test verifying clearDefaultOptions() resets cached defaults so new options are captured upon subsequent loads.

Fixes #1086

How to Test

  1. Initialize TomSelect with virtual_scroll.
  2. Perform an initial empty query load.
  3. Change the data source or filter parameters.
  4. Call instance.clearDefaultOptions() and instance.clearOptions().
  5. Trigger instance.load('') with new results.
  6. Type into the input and clear it (or close the dropdown) — verify that only the new default options are restored.

This branch has not been deployed

No deployments
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.

[plugin: virtual_scroll] Unable to reset preloaded default options when base query or firstUrl changes

1 participant