Skip to content

Commit

Permalink
Merge pull request #157 from pharmaverse/bug/plots-ui-glitch-when-cha…
Browse files Browse the repository at this point in the history
…nging-pages-too-fast

Bug: application glitches when the user changes the pages too fast
  • Loading branch information
m-kolomanski authored Jan 16, 2025
2 parents 66c7fea + 09bc9c0 commit f475182
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
15 changes: 11 additions & 4 deletions inst/shiny/modules/slope_selector.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ slope_selector_ui <- function(id) {
options = list(`actions-box` = TRUE)
),
),
div(align = "left", actionButton(ns("previous_page"), "Previous Page")),
div(align = "left", actionButton(ns("previous_page"), "Previous Page", class = "btn-page")),
div(
align = "center",
tags$span(
Expand All @@ -85,7 +85,7 @@ slope_selector_ui <- function(id) {
uiOutput(ns("page_number"), inline = TRUE)
)
),
div(align = "right", actionButton(ns("next_page"), "Next Page"))
div(align = "right", actionButton(ns("next_page"), "Next Page", class = "btn-page"))
),
# Plots display #
uiOutput(ns("slope_plots_ui"), class = "slope-plots-container", style = "height:70%;"),
Expand All @@ -106,8 +106,14 @@ slope_selector_server <- function(
current_page <- reactiveVal(1)

#' updating current page based on user input
observeEvent(input$next_page, current_page(current_page() + 1))
observeEvent(input$previous_page, current_page(current_page() - 1))
observeEvent(input$next_page, {
current_page(current_page() + 1)
shinyjs::disable(selector = ".btn-page")
})
observeEvent(input$previous_page, {
current_page(current_page() - 1)
shinyjs::disable(selector = ".btn-page")
})
observeEvent(input$select_page, current_page(as.numeric(input$select_page)))
observeEvent(list(input$plots_per_page, input$search_patient), current_page(1))

Expand Down Expand Up @@ -169,6 +175,7 @@ slope_selector_server <- function(
})

output$slope_plots_ui <- renderUI({
shinyjs::enable(selector = ".btn-page")
plot_outputs
})

Expand Down
1 change: 1 addition & 0 deletions inst/shiny/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ fluidPage(
"),

includeCSS(file.path(assets, "style.css")),
includeScript(file.path(assets, "index.js")),

page_navbar(
id = "page",
Expand Down
Empty file added inst/shiny/www/index.js
Empty file.

0 comments on commit f475182

Please sign in to comment.