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

textOutput elements within flipBox -- does not display for tags$h1 #134

Open
McCartneyAC opened this issue Apr 27, 2021 · 2 comments
Open

Comments

@McCartneyAC
Copy link

I'm not sure if this is something broken within shinydashboardPlus, ShinyDashboard, Shiny, or just me, but I've been struggling with it for a while.

In the following two reprexes, one version of h1(textOutput("")) loads if-and-only-if it is not called a second time on the back. Without the second h1(textoutput()) call, it works on the front of the flipbox.

this version works

shinyApp(
  ui = dashboardPage(
    dashboardHeader(),
    dashboardSidebar(),
    dashboardBody(
      fluidRow(
        column(
          width = 6,
          flipBox(
            id = "myflipbox2",
            width = 12,
            front = div(
              h1(textOutput("textsample")),
              img(
                src = "https://image.flaticon.com/icons/svg/149/149076.svg",
                height = "300px",
                width = "100%"
              )
            ),
            back = div(
              height = "300px",
              width = "100%",
             # h1(textOutput("textsample")), # notice this is commented out
              p("More information....")
            )
          )
        )
      )
    )
  ),
  
  server = function(input, output, session) {
    output$textsample <- renderText(
      "this is header text"
    )
  }
)

This version does not display any text

shinyApp(
  ui = dashboardPage(
    dashboardHeader(),
    dashboardSidebar(),
    dashboardBody(
      fluidRow(
        column(
          width = 6,
          flipBox(
            id = "myflipbox2",
            width = 12,
            front = div(
              h1(textOutput("textsample")),
              img(
                src = "https://image.flaticon.com/icons/svg/149/149076.svg",
                height = "300px",
                width = "100%"
              )
            ),
            back = div(
              height = "300px",
              width = "100%",
              h1(textOutput("textsample")), # here it is not commented out, but the previous h1 also does not display. 
              p("More information....")
            )
          )
        )
      )
    )
  ),
  server = function(input, output, session) {
    output$textsample <- renderText(
      "this is header text"
    )
  }
)

Please tell me I'm making a simple mistake somewhere.

@McCartneyAC
Copy link
Author

I will add that in the use case I'm trying to do, it doesn't work even if I include it just once, where I am calling for a character string derived from the server as:

    article1_headline<-renderText(
      newstable %>% 
        dplyr::filter(row_number()==1) %>% 
        dplyr::select(headline) %>% 
        as.character()
    )

h1(textOutput("article1_headline")) has never worked.

@etiennebacher
Copy link

The problem is that you give the same id ("textsample") to two outputs which makes none of them appear. You need to give two different ids.

Regarding your second comment, you should use output$article1_headline instead of article1_headline

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

2 participants