Problem Summary
I have searched thoroughly and I could not find anyone who had asked this same question. I am making a chemical reaction simulation webpage using R Shiny and want to display variables from the most recent simulation to the user. Thus a user can change input variables, but until the action button is pressed again and another reaction simulated, the displayed "variable summary panel" should not change.
The implementation should have been fairly straightforward using observeEvent, renderUI, and htmlOutput, but I have been having issues with the "variable summary panel" reacting to changes in input variables, even without the action button being pressed. Here is some example code:
Example Code
library(shiny)
library(tidyverse)
ui <- fluidPage(
# input variable
tags$p("Reaction Temperature (ºC)"),
sliderInput("temp_initial",NULL,min = 20,max = 70,value = 25),
# action button
actionButton(inputId = "go", label = "Generate Reaction Simulation"),
# summary panel
wellPanel(
tags$p(tags$strong("Simulated input variables")),
htmlOutput("blurb_explanation")
)
)
server <- function(input, output, session) {
# render summary panel text
observeEvent(input$go, ({
output$blurb_explanation <- renderUI(
HTML(paste("<strong> Reaction Temperature (ºC) --></strong>", input$temp_initial))
)
})
)
}
# Run the application
shinyApp(ui = ui, server = server)
Attempted Solutions
I may just have a lack of understanding of Shiny reactivity as I am fairly new to R Shiny. My understanding is that if I pass in input$go as the reactive expression to observeEvent, the body of the function will not run until the go button is pressed again. Right now, after the summary panel is made, any updates in the slider still change the HTML output.
I've tried wrapping the function body in an isolate function, making the observeEvent dependent on other reactive variables, and nothing seems to fix this reactivity problem.
Thank you in advance for your help, this is my first Stack Overflow question, let me know if anything is unclear and I can try to fix.