Skip to content

Broken Shiny table formatting when viewed in flexdashboard #452

@jtesta-deuce

Description

@jtesta-deuce

I have a simple table that is rendered correctly as a Shiny app, but becomes broken when embedded into flexdashboard.

Here is what it looks like as a native Shiny app:

t1

But this happens when its embedded into flexdashboard:

t2

This bug is easy to reproduce. The following native Shiny app code is put into bug_test.R:

library(DT)
library(shiny)

ui_test <- fluidPage(
  sidebarLayout(
    sidebarPanel(),
    mainPanel(
      DT::dataTableOutput("table"),
    )
  )
)

server_test <- function(input, output) {

  output$table <- DT::renderDataTable(DT::datatable({
    colA <- c("A", "B", "C")
    colB <- c("X", "Y", "Z")
    colC <- c("1", "2", "3")
    return(data.frame(colA, colB, colC))
  }), options = list(
    dom = "t",
    ordering = FALSE,
    autoWidth = TRUE,
    columnDefs = list(
      list(className = "dt-right", targets = 1),
      list(width = "150px", targets = 0),
      list(width = "200px", targets = 1),
      list(width = "100px", targets = 2)
    )
  ), selection = "none", rownames = FALSE, escape = FALSE)

}

shinyApp(ui = ui_test, server = server_test)

The flexdashboard code (test.Rmd) is:

---
title: "Test"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: scroll
runtime: shiny
---
Tab Name
=======================================================================

```{r}
source("bug_test.R")

shinyApp(ui = ui_test, server = server_test)
```

I am using the latest version of RStudio (2024.04.2, Build 764), and the latest versions of all modules (Shiny 1.8.1.1, DT 0.33, flexdashboard 0.6.2).

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