Skip to content

Input elements don't work as expected when in a grid container #2

Open
@DivadNojnarg

Description

@DivadNojnarg

Hi @pvictor!

When I put input element within a grid, they stop working. That said, I still see the class shiny-bound-input, so I don't see why it should not work:

library(shiny)
library(bslib)
library(ggplot2)
library(gridstackr)
library(sortable)

ui <- page_fillable(
  tags$h2("GridStack example"),
  layout_sidebar(
    sidebar = sidebar(
      width = 300,
      gridstackOutput("bucket")
    ),
    gs_trash(id = "mytrash", label = "Drag here to remove", height = "50px"),
    gridstackOutput("dashboard")
  )
)

server <- function(input, output, session) {

  output$bucket <- renderGridstack({
    gridstack(
      disableResize = TRUE,
      column = 1,
      options = list(
        acceptWidgets = TRUE,
        dragOut = TRUE
      ),
      gs_item(
        selectInput("variable", "Variable:",
                c("Cylinders" = "cyl",
                  "Transmission" = "am",
                  "Gears" = "gear")),
    tableOutput("data")
    ))
  })

  output$dashboard <- renderGridstack({
    gridstack(
      margin = "10px",
      cellHeight = "140px",
      resize_handles = "all",
      float = TRUE,
      options = list(
        acceptWidgets = TRUE
      ),
      trash_id = "mytrash"
    )
  })

  observeEvent(input$dashboard_layout, {
    print(input$dashboard_layout)
  })

  output$data <- renderTable({
    mtcars[, c("mpg", input$variable), drop = FALSE]
  }, rownames = TRUE)

}

shinyApp(ui, server)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions