Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions R/data_extract_filter_module.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ data_extract_filter_srv <- function(id, datasets, filter) {
)
})

output$html_vals_container <- renderUI({
vals_options <- reactive({
req(input$col)

choices <- value_choices(
data = datasets[[filter$dataname]](),
var_choices = input$col,
Expand All @@ -77,16 +76,38 @@ data_extract_filter_srv <- function(id, datasets, filter) {
} else {
choices[1L]
}
selected <- restoreInput(ns("vals"), selected)
list(choices = choices, selected = selected)
})

output$html_vals_container <- renderUI({
teal.widgets::optionalSelectInput(
inputId = ns("vals"),
label = filter$label,
choices = choices,
selected = selected,
choices = vals_options()$choices,
selected = vals_options()$selected,
multiple = filter$multiple,
fixed = filter$fixed
)
})

# Since we want the input$vals to depend on input$col for downstream calculations,
# we trigger reactivity by reassigning them. Otherwise, when input$col is changed without
# a change in input$val, the downstream computations will not be triggered.
observeEvent(input$col, {
teal.widgets::updateOptionalSelectInput(
session = session,
inputId = "vals",
choices = "",
selected = ""
)
teal.widgets::updateOptionalSelectInput(
session = session,
inputId = "vals",
choices = vals_options()$choices,
selected = vals_options()$selected
)
})
}
)
}
Expand Down