Skip to content

Commit cc0b93c

Browse files
committed
reset: support shinyWidgets' treeInput; this finishes all shinyWidgets inputs; fixes #255
1 parent 7e850e4 commit cc0b93c

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

R/reset.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ reset <- function(id = "", asis = FALSE) {
100100

101101
# list of inputs that can have multiple values and need the value parsed from a
102102
# comma-separated list to a vector
103-
inputsStrToVec <- c("Slider", "SliderDate", "SliderDateTime", "DateRange", "AirDate", "NoUiSlider", "NumericRange", "SliderText", "SlimSelect", "VirtualSelect")
103+
inputsStrToVec <- c("Slider", "SliderDate", "SliderDateTime", "DateRange", "AirDate", "NoUiSlider", "NumericRange", "SliderText", "SlimSelect", "Tree", "VirtualSelect")
104104

105105
if (type %in% inputsStrToVec) {
106106
value <- strToVec(value)
107107
}
108108

109109
# list of inputs that use a 'selected' instead of 'value' argument
110-
inputsParamSelected <- c("RadioButtons", "CheckboxGroup", "Select", "CheckboxGroupButtons", "RadioGroupButtons", "SliderText", "SlimSelect", "Spectrum", "VirtualSelect")
110+
inputsParamSelected <- c("RadioButtons", "CheckboxGroup", "Select", "CheckboxGroupButtons", "RadioGroupButtons", "SliderText", "SlimSelect", "Spectrum", "Tree", "VirtualSelect")
111111
# list of inputs that don't use 'selected' or 'value' arguments
112112
inputsParamOther <- c("DateRange")
113113

@@ -185,7 +185,7 @@ getUpdateFunc <- function(type) {
185185
}
186186

187187
# list of inputs whose update function is taken from {shinyWidgets}
188-
shinyWidgetsInputs <- c("AirDate", "CalendarPro", "CheckboxGroupButtons", "ColorPickr", "Knob", "NoUiSlider", "NumericRange", "RadioGroupButtons", "SliderText", "SlimSelect", "Spectrum", "Time", "VirtualSelect")
188+
shinyWidgetsInputs <- c("AirDate", "CalendarPro", "CheckboxGroupButtons", "ColorPickr", "Knob", "NoUiSlider", "NumericRange", "RadioGroupButtons", "SliderText", "SlimSelect", "Spectrum", "Time", "Tree", "VirtualSelect")
189189

190190
if (type == "Colour") {
191191
pkg <- "colourpicker"

inst/srcjs/shinyjs-default-funcs.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,16 @@ shinyjs = function() {
405405
input = input.children(".sw-time-input");
406406
inputType = "Time";
407407
}
408+
// treeInput
409+
else if (input.children(".tree-widget").length > 0) {
410+
input = input.children(".tree-widget");
411+
inputType = "Tree";
412+
let values = JSON.parse(input.children("script")[0].textContent).values;
413+
if (typeof values === "undefined") {
414+
values = "";
415+
}
416+
inputValue = values;
417+
}
408418
// virtualSelectInput
409419
else if (input.children(".virtual-select").length > 0) {
410420
input = input.children(".virtual-select");

0 commit comments

Comments
 (0)