Skip to content

Commit

Permalink
Work around a selectize bug (re-fixes #3966) (#4142)
Browse files Browse the repository at this point in the history
* Work around a selectize bug (re-fixes #3966)

---------

Co-authored-by: Garrick Aden-Buie <[email protected]>
  • Loading branch information
dvg-p4 and gadenbuie authored Dec 6, 2024
1 parent d37beee commit b6bcfc8
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions inst/www/shared/shiny.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions inst/www/shared/shiny.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion inst/www/shared/shiny.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions inst/www/shared/shiny.min.js.map

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions srcts/src/bindings/input/selectInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b6bcfc8

Please sign in to comment.