When navigating between pages A and B in my shinydashboard app, I noticed that the scroll position of one page affects the scroll position of the other. How do I make the scrolls independent?
To illustrate my issue, I've included a stable shinydashboard app inside shinyGallery:
Even with some CSS and JS code added to my app, I couldn't achieve independent scrolling for each page within the app.
It seems that all shinydashboards exhibit this behavior...
Ideally, I want each page to maintain its scroll position, regardless of how many pages I navigate through.
EDIT
library(shiny)
library(shinydashboard)
header <- dashboardHeader(title = "Dashboard", titleWidth = 320)
sidebar <- dashboardSidebar(
width = 320,
sidebarMenu(
menuItem(
text = "A1",
tabName = "st1"
),
menuItem(
text = "A2",
menuSubItem(
text = "AA1",
tabName = "nd2"
),
menuSubItem(
text = "AA2",
tabName = "rd3"
),
menuSubItem(
text = "AA3",
tabName = "th4"
)
)
)
)
body <- dashboardBody(
HTML(
"<head>
<style>
.small-box {
height: 500px;
}
</style>
</head>"
),
tabItems(
tabItem(
tabName = "st1",
fluidPage(
column(
width = 6,
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow")
)
)
),
tabItem(
tabName = "nd2",
fluidPage(
column(
width = 6,
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow")
)
)
),
tabItem(
tabName = "rd3",
fluidPage(
column(
width = 6,
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow")
)
)
),
tabItem(
tabName = "th4",
fluidPage(
column(
width = 6,
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow"),
valueBox(value = 500, subtitle = "stack overflow")
)
)
)
)
ui <- dashboardPage(header = header, sidebar, body)
server <- function(input, output) {
}
shinyApp(ui, server)
App link.