mirror of
https://github.com/rstudio/shiny.git
synced 2026-04-07 03:00:20 -04:00
Fix selectize bug where value is set merely on query results (#2193)
This bug is new since v1.1. When results are returned from selectize's server-side endpoint, iff no results have been selected before, then the control should be set to either its specified initial value (the one specified in selectInput/selectizeInput) or, if none was provided AND the selectize control is multiple=FALSE, then select the first entry automatically. That's the desired behavior; the bug was that last part, "select the first entry automatically", was happening whether results had already been selected before or not. This was causing merely typing in the control to cause the value to be changed. Fixes #2191
This commit is contained in:
@@ -5353,11 +5353,13 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
||||
selectize.addOptionGroup(elem.group, { group: elem.group });
|
||||
});
|
||||
callback(res);
|
||||
if (!loaded && data.hasOwnProperty('value')) {
|
||||
selectize.setValue(data.value);
|
||||
} else if (settings.maxItems === 1) {
|
||||
// first item selected by default only for single-select
|
||||
selectize.setValue(res[0].value);
|
||||
if (!loaded) {
|
||||
if (data.hasOwnProperty('value')) {
|
||||
selectize.setValue(data.value);
|
||||
} else if (settings.maxItems === 1) {
|
||||
// first item selected by default only for single-select
|
||||
selectize.setValue(res[0].value);
|
||||
}
|
||||
}
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
2
inst/www/shared/shiny.min.js
vendored
2
inst/www/shared/shiny.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -91,11 +91,13 @@ $.extend(selectInputBinding, {
|
||||
selectize.addOptionGroup(elem.group, { group: elem.group });
|
||||
});
|
||||
callback(res);
|
||||
if (!loaded && data.hasOwnProperty('value')) {
|
||||
selectize.setValue(data.value);
|
||||
} else if (settings.maxItems === 1) {
|
||||
// first item selected by default only for single-select
|
||||
selectize.setValue(res[0].value);
|
||||
if (!loaded) {
|
||||
if (data.hasOwnProperty('value')) {
|
||||
selectize.setValue(data.value);
|
||||
} else if (settings.maxItems === 1) {
|
||||
// first item selected by default only for single-select
|
||||
selectize.setValue(res[0].value);
|
||||
}
|
||||
}
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user