I developed a shiny app with different modules and files and I have some issues with my updateTabsetPanel :
A main file where each tab item are a different module in a different file.
I have the module explore and annotate which are call like this:
#### in the main app
server <- function(input,output,session){
ns <- session$ns
## Sidebar panel for inputs
output$menu <- renderMenu({
sidebarMenu(id = "tabs_menu",
menuItem("Input data",tabName ="datafile", icon = icon("file-import")),
menuItem("Explore", tabName = "explore", icon = icon("microscope")),
menuItem("Annotate", tabName = "annotate", icon = icon("edit")),
menuItem("Clusters", tabName = "cluster", icon = icon("asterisk"))
)})
global_data <- callModule(Module_input_data_server, "data_module" )
#Module explore
observeEvent(input$tabs_menu,{
if(input$tabs_menu=="explore"){
callModule(Module_explore_server, "explore_module", global_data )
}
}, ignoreNULL = TRUE, ignoreInit = TRUE)
#Module annotate
observeEvent(input$tabs_menu,{
if(input$tabs_menu=="annotate"){
callModule(Module_annotate_server, "annotate_module",global_data)
}
}, ignoreNULL = TRUE, ignoreInit = TRUE)
}
In the explore module I have different modules, one is the table I would like to return thank to the module annotate after a click on on a button. So the goal is to return to explore after the click on the action button. but it's doesn't work.
#### in the annotate module the observe event for the click button
Module_annotate_server <- function(input, output,session, rv) {
req(rv$data)
ns <- session$ns
observeEvent(input$annotateButton,{
req(rv$data)
print("how")
# if(is.null(rv$secure)){
if(!is.null(input$newCol) && input$newCol != "") {
print("how1")
new.column <- rep(NA,nrow(rv$data))
rv$data <- cbind(rv$data, new.column)
colnames(rv$data)[ncol(rv$data)] <- input$newCol
rv$annotationCol <- input$newCol
} else if(!is.null(input$annotationCol) && input$annotationCol != "") {
print("how2")
rv$annotationLabels <- unique(rv$data[,input$annotationCol])
rv$annotationCol <- input$annotationCol
}
if(length(input$labelsList)>0) {
print("how3")
new.labels <- unlist(strsplit(input$labelsList, "\\s*,\\s*"))
if(length(new.labels)>0) {
rv$annotationLabels <- c(input$annotationLabels, new.labels)
}
}
if(is.null(rv$annotationLabels) || length(rv$annotationLabels) == 0) {
showNotification("Some labels must be provided.", type ="error", duration = NULL)
} else {
# Move to the Explore tab
updateTabsetPanel(session , "tabs_menu", selected = "explore")
}
}
I would like to know what is the problem maybe the session or other things if you have idea.
Thank you!