Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(updateSelectizeInput): Clear current value before update if selected and sever = TRUE #3967

Merged
merged 8 commits into from
Mar 14, 2024

Conversation

gadenbuie
Copy link
Member

@gadenbuie gadenbuie commented Jan 9, 2024

When a user calls updateSelectizeInput() with server = TRUE and they provide both new choices (required by server = TRUE) and a new selected value, the current value of the select input may not be part of choices. When the old value isn't in choices, those options will remain in the select options after the options are updated.

This PR updates the client-side JS for a server = TRUE update to clear the current select input value when selected is provided, to avoid the persistence of the old values in the select options.

When selected is not provided, we'll still run into the previous behavior, but I don't know if there's anything we can do about that since the client doesn't have complete information about the set of choices.

Fixes #3966

@cpsievert
Copy link
Collaborator

Just noting that .clearOptions() did in fact intentionally make this change (of not .clear()-ing the selection) in v0.15.2:

selectize/selectize.js@5b15d3b
selectize/selectize.js#1079

However, the docs didn't get updated to reflect this 😞

https://selectize.dev/docs/API/selectize#clearoptionssilent

Screenshot 2024-03-13 at 5 32 55 PM

Copy link
Collaborator

@cpsievert cpsievert left a comment

Choose a reason for hiding this comment

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

Nice catch and fix, thanks!

@cpsievert cpsievert merged commit c1a1542 into main Mar 14, 2024
12 checks passed
@cpsievert cpsievert deleted the fix/selectize-server-side-update branch March 14, 2024 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants