From 471f2773aa85b99f982bdd23aad4583686f94b0a Mon Sep 17 00:00:00 2001 From: Elias Projahn Date: Fri, 17 Dec 2021 13:14:42 +0100 Subject: [PATCH] methods: Automatically change to custom weighting --- R/methods.R | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/R/methods.R b/R/methods.R index adcf801..92b83df 100644 --- a/R/methods.R +++ b/R/methods.R @@ -45,11 +45,18 @@ methods_server <- function(id, analysis) { moduleServer(id, function(input, output, session) { # Observe each method's enable button and synchronise the slider state. lapply(methods, function(method) { - observeEvent(c(input[[method$id]], input$optimization_target), { + observeEvent(input[[method$id]], { shinyjs::toggleState( sprintf("%s_weight", method$id), - condition = input$optimization_target == "custom" & - input[[method$id]] + condition = input[[method$id]] + ) + }) + + shinyjs::onclick(sprintf("%s_weight", method$id), { + updateSelectInput( + session, + "optimization_target", + selected = "custom" ) }) })