Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 更新notificationMenuOutput-奇怪重定向到其他选项卡_R_Shiny_Dplyr_Shinydashboard - Fatal编程技术网

R 更新notificationMenuOutput-奇怪重定向到其他选项卡

R 更新notificationMenuOutput-奇怪重定向到其他选项卡,r,shiny,dplyr,shinydashboard,R,Shiny,Dplyr,Shinydashboard,我有一个ShinyDashboard页面,标题中有一个notificationMenu。我从仪表板的页面中更新这些通知。这很好,但在更新通知项后,用户会被重定向到应用程序的第一个选项卡,这是一种奇怪的行为。即使在更新被触发后,我也希望保持在当前页面。有人有解释吗 library(shiny) library(shinydashboard) library(dplyr) ui <- dashboardPage(dashboardHeader(dropdownMenuOutput("noti

我有一个ShinyDashboard页面,标题中有一个notificationMenu。我从仪表板的页面中更新这些通知。这很好,但在更新通知项后,用户会被重定向到应用程序的第一个选项卡,这是一种奇怪的行为。即使在更新被触发后,我也希望保持在当前页面。有人有解释吗

library(shiny)
library(shinydashboard)
library(dplyr)

ui <- dashboardPage(dashboardHeader(dropdownMenuOutput("notificationMenu")), 
                    dashboardSidebar(sidebarMenu(menuItem("Page 1", tabName = "page1"),
                                                 menuItem("Page 2", tabName = "page2"))),
                    dashboardBody(tabItems(
                      tabItem(tabName = "page1", h4("This is Page 1")),
                      tabItem(tabName = "page2", 
                              textInput("text", "Enter News:", "New News."),
                              actionButton("save", "Save")))))

server <- function(input, output, session){
  raw_news <- reactiveValues()

  # Intial Header News: 1 Message from Admin
  raw_news$news <- data_frame(from = "Admin", text = "this is a message")

  # The notifications in header
  output$notificationMenu <- renderMenu({
    raw_news <- raw_news$news

    dropdownMenu(
      messageItem(raw_news$from[1], raw_news$text[1])
    )
  })

  # save a new notification
  observeEvent(input$save, {
    raw_news$news <- data.frame(from = "User", text = input$text)
  }) 
}

shinyApp(ui = ui, server = server)
库(闪亮)
图书馆(shinydashboard)
图书馆(dplyr)

ui这确实是shinydashboard
包中的一个bug,已经在0.6.1.9000版中修复。到目前为止,它还不在CRAN上,所以github的devtools版本应该可以,或者还有一个解决方法:添加

sidebar菜单(id=“sidebar”

updateBitEMS(会话,“侧栏”,输入$sidebar)

输出$notificationMenu

更多信息:

issue://解决方法: