|
1 | 1 | # Run this app to test that Shiny outputs that are initally hidden inside
|
2 | 2 | # menuItems become visible ( trigger("shown) ) after we expand the respective
|
3 |
| -# menuItem. Currently, this doesn't look exactly pretty, but it does work. |
4 |
| -# |
5 |
| -# ------------------------------------------------------------------------------ |
6 |
| -# |
7 |
| -# Aside from being ugly, this app also shows another unfortunate side effect |
8 |
| -# of the hacky code for the trigger("shown) of Shiny outputs. Which is that |
9 |
| -# the ensureActivatedTab() function does not work on app startup if the only |
10 |
| -# tabNamed things are initially hidden inside the menuItem parents. |
11 |
| -# |
12 |
| -# To see this, go to this app URL: |
13 |
| -# http://127.0.0.1:4601/?_inputs_&sidebarCollapsed=%22false%22&sidebarItemExpanded=%22tabName%22&smenu=null |
14 |
| -# You will see that even though `smenu` is "null" the `name` tab (menuSubItem) |
15 |
| -# appears highlighted, as it should be if the ensureActivatedTab() function is |
16 |
| -# doing its job. |
17 |
| -# But if you do this "manually", even though you get the *SAME* bookmarked URL, |
18 |
| -# you don't see the `name` tab highlighted...: |
19 |
| -# 1) Go to http://127.0.0.1:4601/ |
20 |
| -# 2) Click on the "Menu Item 1" to expand it |
21 |
| -# 3) Check with abadonment and dismay that the URL looks the same as above, |
22 |
| -# but that the `name` tab is *NOT* highlighted |
23 |
| -# 4) Regain some faith and hope through the fact that at least the content |
24 |
| -# ("This is the only content") always appears, so while something if off |
25 |
| -# with ensureActivatedTab(), it's still doing its most important job, |
26 |
| -# which is to display some/any content on the dashboardBody if there is |
27 |
| -# a menuItem or menuSubItem anywhere in the dashboardSidebar with a |
28 |
| -# tabName and a corresponding tabItem anywhere in the dashboardBody |
29 |
| -# |
30 |
| -# ------------------------------------------------------------------------------ |
31 |
| -# |
32 |
| -# This also shows that you can only bookmark the expanded menuItem *IF* at least |
33 |
| -# one of its children is a menuSubItem *with* a tabName. |
| 3 | +# menuItem. |
34 | 4 |
|
35 | 5 | library(shiny)
|
36 | 6 | library(shinydashboard)
|
37 | 7 |
|
38 |
| -options(shiny.launch.browser=F, shiny.minified=F, shiny.port = 4601) |
| 8 | +options(shiny.launch.browser=F, shiny.minified=F, shiny.port = 9000) |
39 | 9 |
|
40 | 10 | ui <- function(req) {
|
41 | 11 | dashboardPage(
|
42 | 12 | dashboardHeader(),
|
43 | 13 | dashboardSidebar(
|
44 | 14 | sidebarMenu(id = "smenu",
|
45 | 15 | menuItem("Menu Item 1", tabName = "tab1", "text1", menuSubItem("name", tabName = "tabName")),
|
46 |
| - menuItem("Menu Item 2", tabName = "tab2", textOutput("text2")) |
| 16 | + menuItem("Menu Item 2", tabName = "tab2", textOutput("text2"), startExpanded = FALSE, |
| 17 | + expandedName = "expanded") |
47 | 18 | )
|
48 | 19 | ),
|
49 | 20 | dashboardBody(
|
|
0 commit comments