Exiting out of renderDT causes bootstrap problems
Situation: There are two DT tables with 100 rows each. The second renderDT depends on the value of a selection on the first table. If nothing is selected it exists out through a if(nothing selected) return().
Problem: This works perfectly as designed, except when style = "bootstrap". In that instance, the pagination UI of the tables breaks. There is extra padding around the buttons and it does not show as designed.
run the app as is, and then run it with the if statement commented out to see what I mean.
library(shiny)
library(DT)
dt <- data.frame(colA = sample(c("one","two"),10,replace=T), ColB = rnorm(100))
ui <- basicPage(
DTOutput("test_table1"),
DTOutput("test_table2")
)
server <- function(input, output) {
output$test_table1 <- renderDT({
datatable(dt, style = "bootstrap")
})
output$test_table2 <- renderDT({
if(is.null(input$test_table1_rows_selected)) return()
datatable(dt, style = "bootstrap")
})
}
shinyApp(ui = ui, server = server)
Results:

Expected:

By filing an issue to this repo, I promise that
- [x] I have fully read the issue guide at https://yihui.name/issue/.
- [x] I have provided the necessary information about my issue.
- If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
- If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included
xfun::session_info('DT'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('rstudio/DT'). - If I have posted the same issue elsewhere, I have also mentioned it in this issue.
- [x] I have learned the Github Markdown syntax, and formatted my issue correctly.
I understand that my issue may be closed if I don't fulfill my promises.
Actually, the whole bootstrap theme breaks, I just hadn't notice. It's most evident on the pagination, but the whole bootstrap theme is not observed.
@guasi please see https://github.com/rstudio/DT/issues/834#issuecomment-673778953
When return(), DT assumes the basic theme and causes conflicts with theme bootstrap in another table, as the DT themes are incompatible and can't be used on the same page.
I agree it's confusing. The only way to fix this is to have a global option and warn it when two themes are found on the same page.