I am programming a larger shiny interface, with an ui.r mainPanel containing a tabsetPanel with several tabPanels and within each such different kinds of table and plot outputs. It looks great, except that pages which need to be scrolled tend to jump in their scrolling positions upon, e.g., (re)selecting plot outputs, table entries, etc. Jumps sometimes go to the beginning of the page, sometimes elsewhere; they arise in both Firefox and Chrome. Thus, is there any way to prevent or suppress such jumping? Thank you very much for your help.
Below is a minimal example, in which the ui jumps to the top of the page after a selection is made in the table rows at the bottom of the page:
library(shiny)
library(DT)
data=data.frame(x=1:10,y=2:11)
ui=shinyUI(
fluidPage(
plotOutput("plot1"),
plotOutput("plot2"),
DT::dataTableOutput("tt")
)
)
server=shinyServer(function(input, output) {
dd=reactiveValues(d=data)
output$plot1 <- renderPlot({plot(0,1)})
output$plot2 <- renderPlot({plot(0,1)})
output$tt=DT::renderDataTable(
datatable(
dd$d,selection =c('single')
)
)
observeEvent(input$tt_rows_selected,{
dd$d[input$tt_rows_selected,1]<-log(dd$d[input$tt_rows_selected,1])
})
})
shinyApp(ui,server)