You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've run into an issue where I am feeding a reactive node list into the renderjstree function inside of a module, and the jstree does not update properly when the reactive updates. To get around this, a previous issue recommended using the jstreeDestroy function before updating the jstree data structure. I was able to update the jstree by doing this, but the search bar does not get destroyed.
3 things stood out to me while investigating this:
The search bar is not properly destroyed by the jstreeDestroy function. (issue)
Shouldn't jstreeDestroy be automatically called on any re-renders? (feature request)
Note that for modular shiny functions, the jstreeDestroy function does not properly handle the different namespaces. (issue or feature request)
This is my minimal example below:
library(shiny)
library(jsTreeR)
#Module with jstree
jstreeUI <- function(id) {
ns <- NS(id)
jstreeOutput(ns('tree'))
}
jstreeServer <- function(input,output,session,nodes=reactive(NULL)) {
output$tree <- renderJstree({
#Destroy the tree each time
jstreeDestroy(session, session$ns('tree'))
#Call the tree
jsTreeR::jstree(
nodes = nodes(),
search = TRUE,
multiple = FALSE,
theme = "proton")
})
}
#Main ui and server functions
mainUI <- fluidPage(
checkboxInput('list1','A',value=T),
jstreeUI('a')
)
mainServer <- function(input,output, session) {
#Update the data structure when the checkbox changes
nodes <- reactive({
if (input$list1) {
return(list(list(text = "AAAAAAA")))
} else {
return(list(list(text = "BBBBBBB")))
}
})
#Call module with jstree
callModule(module=jstreeServer, id='a', nodes=nodes)
}
#Run shiny app
shinyApp(ui = mainUI, server = mainServer)
The text was updated successfully, but these errors were encountered:
I've run into an issue where I am feeding a reactive node list into the renderjstree function inside of a module, and the jstree does not update properly when the reactive updates. To get around this, a previous issue recommended using the jstreeDestroy function before updating the jstree data structure. I was able to update the jstree by doing this, but the search bar does not get destroyed.
3 things stood out to me while investigating this:
This is my minimal example below:
The text was updated successfully, but these errors were encountered: