rstudio / rstudio/flexdashboard

Broken Shiny table formatting when viewed in flexdashboard

Open
#452 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
848
Forks
298
PR merge metrics
No merged PRs in 30d

Description

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).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run bug_test.R as a native Shiny app, then render test.Rmd with flexdashboard to compare the table output. Inspect the table formatting in the embedded dashboard and the flexdashboard integration; done means the table widths, alignment, and layout match the native Shiny result.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.