Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unwanted apparition of shiny output #389

Open
stla opened this issue Oct 3, 2020 · 1 comment
Open

Unwanted apparition of shiny output #389

stla opened this issue Oct 3, 2020 · 1 comment

Comments

@stla
Copy link

stla commented Oct 3, 2020

Hello,

I did a htmlwidget which renders some text in a blue div: findInFiles.

I noticed two strange issues with the Shiny output.

First, when I include the Shiny output in the UI without including the Shiny render in the server, the blue div permanently appears:

library(findInFiles)
library(shiny)

onKeyDown <- HTML(
  'function onKeyDown(event) {',
  '  var key = event.which || event.keyCode;',
  '  if(key === 13) {',
  '    Shiny.setInputValue(',
  '      "pattern", event.target.value, {priority: "event"}',
  '    );',
  '  }',
  '}'
)

ui <- fluidPage(
  tags$head(tags$script(onKeyDown)),
  br(),
  sidebarLayout(
    sidebarPanel(
      selectInput(
        "ext", "Extension",
        choices = c("R", "js", "css")
      ),
      tags$div(
        class = "form-group shiny-input-container",
        tags$label(
          class = "control-label",
          "Pattern"
        ),
        tags$input(
          type = "text",
          class = "form-control",
          onkeydown = "onKeyDown(event);",
          placeholder = "Press Enter when ready"
        )
      ),
      numericInput(
        "depth", "Depth (set -1 for unlimited depth)",
        value = 0, min = -1, step = 1
      ),
      checkboxInput(
        "wholeWord", "Whole word"
      ),
      checkboxInput(
        "ignoreCase", "Ignore case"
      )
    ),
    mainPanel(
      FIFOutput("results")
    )
  )
)


server <- function(input, output){

  # output[["results"]] <- renderFIF({
  #   req(input[["pattern"]])
  #   findInFiles(
  #     ext = isolate(input[["ext"]]),
  #     pattern = input[["pattern"]],
  #     depth = isolate(input[["depth"]]),
  #     wholeWord = isolate(input[["wholeWord"]]),
  #     ignoreCase = isolate(input[["ignoreCase"]])
  #   )
  # })

}

shinyApp(ui, server)

FFIoutput

Secondly, if I include the Shiny render (by uncommenting in server above), the blue div appears as a flash (it appears during a small amount of time) while it is not rendered yet (input[["pattern"]] in the app above is NULL). I recorded a GIF of the app and I slowed it down:

FIFOutput

Actually there's a third strange issue. Did you notice in the above GIF that the style of the selectInput changes when the blue div appears? Here is the image of this moment:

FIFOutput-00054

Cheers.

@stla
Copy link
Author

stla commented Oct 3, 2020

Stupid of me... I've just (partially) understood. FIFOutput generates a div with the findInFiles class, so the first point is normal!

But why the change of style of the selectInput ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant