jsTreeR icon indicating copy to clipboard operation
jsTreeR copied to clipboard

jsTreeR affects other htmlwidgets' styling

Open datatenk opened this issue 2 months ago • 2 comments

After switching from shinyTree to jsTreeR, all other htmlwidgets appear to have their styling set to those of jsTree when they are rendered through renderUI.

As exemplified below, a shinyWidgets::radioGroupButtons element is used:

  1. when using shinyTree, the following rendering is obtained (desirable): Screenshot 2024-05-05 215821

  2. after switching to jsTreeR, the following rendering is obtained (undesirable): Screenshot 2024-05-05 215745

Below is a reprex, firstly using shinyTree, where the renderings are good in both "shinyTree" and "shinyTree uiOutput" tabs:

library(shiny)
library(bslib)
library(shinyWidgets)
library(shinyTree)
library(jsTreeR)

# using shinyTree
nodes_shinyTree<-list(foo=list(bar=list()))

shinyTree_ui<-card(
  shinyTree('shinyTree_tree_ui'),
  radioGroupButtons('rgb1',choices=c('A','B'),size='sm'))

ui_shinyTree<-page_navbar(
  title='shinyTree',
  
  nav_panel(
    title='shinyTree',
    card(
      shinyTree('shinyTree_tree'),
      radioGroupButtons('rgb',choices=c('A','B'),size='sm')
    )
  ),

  nav_panel(
    title='shinyTree uiOutput',
    uiOutput('shinyTree_ui')
  )
  
)

server_shinyTree<-function(input,output,session){
  output$shinyTree_tree<-renderTree(nodes_shinyTree)
  
  output$shinyTree_tree_ui<-renderTree(nodes_shinyTree)
  output$shinyTree_ui<-renderUI(shinyTree_ui)
  
  
}

shinyApp(ui_shinyTree,server_shinyTree)

Same example, now using jsTreeR instead of shinyTree; notice the problem in the "jsTreeR uiOutput" tab:

library(shiny)
library(bslib)
library(shinyWidgets)
library(shinyTree)
library(jsTreeR)


# using jsTreeR
nodes_jsTreeR<-list(list(text='foo',children=list(list(text='bar'))))

jsTreeR_ui<-card(
    jstreeOutput('jstree_tree_ui'),
    radioGroupButtons('rgb1',choices=c('A','B'),size='sm'))


ui_jsTreeR<-page_navbar(
  title='jsTreeR',
  
  nav_panel(
    title='jsTreeR',
    card(
      jstreeOutput('jstree_tree'),
      radioGroupButtons('rgb',choices=c('A','B'),size='sm')
    )
  ),

  nav_panel(
    title='jsTreeR uiOutput',
    uiOutput('jsTreeR_ui')
  )
)

server_jsTreeR<-function(input,output,session){
  output$jstree_tree<-renderJstree(jstree(nodes_jsTreeR))
  
  output$jsTreeR_ui<-renderUI(jsTreeR_ui)
  output$jstree_tree_ui<-renderJstree(jstree(nodes_jsTreeR))
  
}

shinyApp(ui_jsTreeR,server_jsTreeR)

datatenk avatar May 06 '24 04:05 datatenk