Work around a selectize bug (re-fixes #3966) (#4142)

* Work around a selectize bug (re-fixes #3966)

---------

Co-authored-by: Garrick Aden-Buie <garrick@adenbuie.com>
This commit is contained in:
Dan Gealow
2024-12-06 15:03:59 -05:00
committed by GitHub
parent d37beeece7
commit b6bcfc8683
6 changed files with 14 additions and 14 deletions

View File

@@ -22,6 +22,8 @@
* Fixed a bug with stack trace capturing that caused reactives with very long async promise chains (hundreds/thousands of steps) to become extremely slow. Chains this long are unlikely to be written by hand, but {coro} async generators and {elmer} async streaming were easily creating problematically long chains. (#4155)
* Updating the choices of a `selectizeInput()` via `updateSelectizeInput()` with `server = TRUE` no longer retains the selected choice as a deselected option if the current value is not part of the new choices. (@dvg-p4 #4142)
# shiny 1.9.1
## Bug fixes

View File

@@ -10662,10 +10662,8 @@
}
if (hasDefinedProperty(data, "url")) {
var _selectize2 = this._selectize(el);
_selectize2.clear();
_selectize2.clearOptions();
if (hasDefinedProperty(data, "value")) {
_selectize2.clear();
}
var loaded = false;
_selectize2.settings.load = function(query, callback) {
var settings = _selectize2.settings;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -142,13 +142,13 @@ class SelectInputBinding extends InputBinding {
};
};
// Calling selectize.clear() first works around https://github.com/selectize/selectize.js/issues/2146
// As of selectize.js >= v0.13.1, .clearOptions() clears the selection,
// but does NOT remove the previously-selected options. So unless we call
// .clear() first, the current selection(s) will remain as (deselected)
// options. See #3966 #4142
selectize.clear();
selectize.clearOptions();
// If a new `selected` value is provided, also clear the current selection (otherwise it gets added as an option).
// Note: although the selectize docs suggest otherwise, as of selectize.js >v0.15.2,
// .clearOptions() no longer implicitly .clear()s (see #3967)
if (hasDefinedProperty(data, "value")) {
selectize.clear();
}
let loaded = false;
selectize.settings.load = function (query: string, callback: CallbackFn) {