rstudio / rstudio/bslib

cant update active/selected row background color for datatables

Open
#811 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
SCSS
Stars
569
Forks
72
Avg merge
1d 2h
Merged PRs (30d)
5

Description

Updating table-active-bg has no effect for preset of "shiny" or "bootstrap", while table-color does work, for instance. See reprex:

library(shiny)
library(DT)

my_theme <- bslib::bs_theme(
  version = 5
)

my_theme <- bslib::bs_add_variables(
  my_theme,
  'table-active-bg' = 'red',
  'table-color' = 'purple'
)

ui <- bslib::page_navbar(
  theme=my_theme,
  bslib::nav_panel('test', DT::DTOutput('table'))
)

server <- function(input, output, session) {
  output$table <- DT::renderDT({
    mtcars
  })
}

shinyApp(ui, server)

Noticing also that there may be mixed use of selected and active classes when selecting datatable rows. Not sure which is the right one. I'm using the following code from tables/_rules.scss as reference to make me think I should update table-active-bg:

  tbody td.active,
  tbody tr.active td {
    background-color: var(--bs-table-active-bg);
  }

Contributor guide

No contributing guide indexed for this repository

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

Reproduce the behavior with the supplied Shiny and DT example, then inspect tables/_rules.scss and the active versus selected classes emitted by DT. Confirm which selector controls selected rows and verify that changing table-active-bg affects the relevant rows for the shiny and bootstrap presets.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.