Skip to content

[Autocomplete] support reset on focus#3422

Open
zairigimad wants to merge 3 commits intosymfony:2.xfrom
zairigimad:fix/autocomplete-3415
Open

[Autocomplete] support reset on focus#3422
zairigimad wants to merge 3 commits intosymfony:2.xfrom
zairigimad:fix/autocomplete-3415

Conversation

@zairigimad
Copy link
Copy Markdown
Contributor

Q A
Bug fix? yes
New feature? no
Deprecations? no
Documentation? no
Issues Fix #3415
License MIT

It’s not actually a bug, but the default behavior of Tom Select.
When the preload option is set to focus (which is the default), it fetches the data once and then reuses the cache to avoid triggering a request every time the select is opened.

With this PR, a new option is introduced to let you control whether the state should be reset on focus or not.

@carsonbot carsonbot added Autocomplete Bug Bug Fix Status: Needs Review Needs to be reviewed labels Mar 30, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 30, 2026

📊 Packages dist files size difference

Thanks for the PR! Here is the difference in size of the packages dist files between the base branch and the PR.
Please review the changes and make sure they are expected.

FileBefore (Size / Gzip)After (Size / Gzip)
Autocomplete
controller.d.ts 1.83 kB / 655 B 1.91 kB+4% 📈 / 667 B+2% 📈
controller.js 12.93 kB / 3.45 kB 13.3 kB+3% 📈 / 3.54 kB+3% 📈

@zairigimad zairigimad force-pushed the fix/autocomplete-3415 branch from 5a89168 to 814ab69 Compare March 30, 2026 18:18
@brianfreytag
Copy link
Copy Markdown

brianfreytag commented Mar 31, 2026

Thanks for the clarification on the default functionality and I agree that an additional option here is the best solution.

I do want to clarify that it's not just on "focus" or "change" events, it's when the reset X is pressed as well to clear the input. Would it not make sense that the default functionality of "clear" would be to actually reset the select options than maintain the cached version? I guess in my mind, if I'm clearing the input, I'm trying to go back to the original state whether I begin a new search or decide I want to scroll this time.

This question to ask, I suppose, is, "Should the default value for reset_on_focus be true in instances of the "clear" button?" and is this something to take up with the TomSelect folks or a "workaround" on the Symfony side?

@Kocal Kocal added Feature New Feature and removed Bug Bug Fix labels Apr 3, 2026
Copy link
Copy Markdown
Member

@Kocal Kocal left a comment

Choose a reason for hiding this comment

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

Since it's not really a bug but a feature, can you add a new changelog entry for 2.35 please?

Thanks!

Comment on lines +331 to +334
(this.tomSelect as any).loadedSearches = {};
if (typeof (this.tomSelect as any).clearPagination === 'function') {
(this.tomSelect as any).clearPagination();
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please remove the as any, it's often a bad practice, and it does not make sense here AFAIK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Autocomplete Feature New Feature Status: Needs Review Needs to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[AutoComplete] Ajax List Does Not Reset when Cleared

4 participants