1

For my shinyapp, I am currently trying to implement a conditionalPanel in the sidebar. It is working fine, if I don't use recaptcha button at the end for submission. But with recaptcha button, the conditional Panel does not work.

I am using the shinyCAPTCHA library for this.

I also tried attaching recaptha to both the conditional panels separately, but even then the conditionalpanel functionality does not work.

I guess it has something to do with the way recaptchaUI is coded in terms of location of the UI box, however I am not sure how to solve the issue.

GIFs of usage are attached here:

  1. Without recaptcha, conditional panel works fine Conditional panel working without recaptcha

  2. With recaptcha button added, the panel for "request" input choice just disappears. Conditional Panel not working with recaptcha

The code is here: (you will need to generate and enter a sitekey to run this :| )

# setup -------------------------------------------------------------------
library(shiny)
library(shinyjs)
library(leaflet)
library(data.table)
library(shinyCAPTCHA)



# Define UI for application 

ui <- fluidPage(
    div(h1("Application Title"),
        h3("Application description"),align = "center"),

    # Sidebar with a slider input for number of bins
    sidebarLayout(
        sidebarPanel(
            # div(
            h4("Register/Request for a new site"),
            shinyjs::useShinyjs(),
            radioButtons("registerorrequest",
                         "Register or Request: ",
                         choiceValues = list("register","request"),
                         choiceNames = c(
                             "Register your entity",
                             "Request for an entity"
                         ),
                         selected = NULL),
            
            conditionalPanel(
                condition = "input.registerorrequest == 'register'",
                numericInput("A","Input A for register",value = 0),
                radioButtons("B","Input B for register: ",
                             choices = c(
                                 "X",
                                 "Y",
                                 "Z",
                                 "Other"
                             ),selected = NULL),
                radioButtons("C", "Input C for register: ",
                             choices = c(
                                 "more choices",
                                 "other choices"),selected = NULL),
                radioButtons("D","Input D for register:",
                             choices = c("Yes","No"),selected = NULL)
            ),
            conditionalPanel(
                condition = "input.registerorrequest == 'request'",
                radioButtons("P", "Input P for request: ",
                             choices = c(
                                 "some choices",
                                 "some more choices"),selected = NULL),
            ),
            div(textInput("additionalinput","Any additional input",value = ""),
                recaptchaUI("test", sitekey = "enterSitekey"),
                uiOutput("humansOnly"),
                style = "font-family:Arial"),
            width = 4
        ),
        
        # Show a plot of the generated distribution
        mainPanel()))

    # Define server logic 
    server <- function(input, output) {}
    
    # Run the application 
    shinyApp(ui = ui, server = server)

Any input to solve this would be of great help to me. Thank you!

noddy157
  • 31
  • 4

0 Answers0