Skip to content

Commit 6782355

Browse files
committed
Merge pull request rstudio#939 from yihui/bugfix/selectize-selected
Fixes rstudio#929: defer setValue() for selectize until the options have been loaded from server
2 parents e6fd30f + 273e71e commit 6782355

File tree

8 files changed

+27
-29
lines changed

8 files changed

+27
-29
lines changed

R/update-input.R

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -474,13 +474,9 @@ updateSelectizeInput <- function(session, inputId, label = NULL, choices = NULL,
474474
return(updateSelectInput(session, inputId, label, choices, selected))
475475
}
476476
value <- unname(selected)
477-
selected <- choicesWithNames(selected)
478477
message <- dropNulls(list(
479478
label = label,
480479
value = value,
481-
selected = if (length(selected)) {
482-
columnToRowData(list(label = names(selected), value = selected))
483-
},
484480
url = session$registerDataObj(inputId, choices, selectizeJSON)
485481
))
486482
session$sendInputMessage(inputId, message)
@@ -494,7 +490,7 @@ selectizeJSON <- function(data, req) {
494490
# all keywords in lower-case, for case-insensitive matching
495491
key <- unique(strsplit(tolower(query$query), '\\s+')[[1]])
496492
if (identical(key, '')) key <- character(0)
497-
mop <- query$maxop
493+
mop <- as.numeric(query$maxop)
498494

499495
# convert a single vector to a data frame so it returns {label: , value: }
500496
# later in JSON; other objects return arbitrary JSON {x: , y: , foo: , ...}

inst/www/shared/selectize/css/selectize.bootstrap3.css

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* selectize.bootstrap3.css (v0.11.2) - Bootstrap 3 Theme
3-
* Copyright (c) 2013 Brian Reavis & contributors
2+
* selectize.bootstrap3.css (v0.12.1) - Bootstrap 3 Theme
3+
* Copyright (c) 2013–2015 Brian Reavis & contributors
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
66
* file except in compliance with the License. You may obtain a copy of the License at:
@@ -115,8 +115,8 @@
115115
.selectize-input,
116116
.selectize-input input {
117117
color: #333333;
118-
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
119-
font-size: 14px;
118+
font-family: inherit;
119+
font-size: inherit;
120120
line-height: 20px;
121121
-webkit-font-smoothing: inherit;
122122
}
@@ -227,7 +227,7 @@
227227
.selectize-dropdown {
228228
position: absolute;
229229
z-index: 10;
230-
border: 1px solid #cccccc;
230+
border: 1px solid #d0d0d0;
231231
background: #ffffff;
232232
margin: -1px 0 0 0;
233233
border-top: 0 none;
@@ -398,4 +398,4 @@
398398
-webkit-border-radius: 0;
399399
-moz-border-radius: 0;
400400
border-radius: 0;
401-
}
401+
}

inst/www/shared/selectize/js/selectize.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inst/www/shared/shiny.js

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inst/www/shared/shiny.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inst/www/shared/shiny.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inst/www/shared/shiny.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

srcjs/input_binding_select.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ $.extend(selectInputBinding, {
5555
if (data.hasOwnProperty('url')) {
5656
selectize = this._selectize(el);
5757
selectize.clearOptions();
58+
var thiz = this, loaded = false;
5859
selectize.settings.load = function(query, callback) {
5960
var settings = selectize.settings;
6061
$.ajax({
@@ -71,19 +72,19 @@ $.extend(selectInputBinding, {
7172
},
7273
success: function(res) {
7374
callback(res);
75+
if (!loaded && data.hasOwnProperty('value'))
76+
thiz.setValue(el, data.value);
77+
loaded = true;
7478
}
7579
});
7680
};
7781
// perform an empty search after changing the `load` function
7882
selectize.load(function(callback) {
7983
selectize.settings.load.apply(selectize, ['', callback]);
8084
});
81-
if (data.hasOwnProperty('selected'))
82-
selectize.addOption(data.selected);
83-
}
84-
85-
if (data.hasOwnProperty('value'))
85+
} else if (data.hasOwnProperty('value')) {
8686
this.setValue(el, data.value);
87+
}
8788

8889
if (data.hasOwnProperty('label'))
8990
$(el).parent().parent().find('label[for="' + $escape(el.id) + '"]').text(data.label);

0 commit comments

Comments
 (0)