rhandsontable expands infinitely after setting overflow = 'visible'

72 Views Asked by At

I'm trying to integrate an rhandsontable into a Shiny app I'm working on but ran into a problem where drop down menus got cut off for short tables. After searching around, I found a number of resources suggesting the solution is to add overflow = 'visible' as an argument to rhandsontable (like this one and this one). This did stop the drop downs from getting cut off, but introduced a new problem where the app expands infinitely vertically. The following code reproduces the issue:

library(shiny)
library(bslib)
library(gridlayout)
library(rhandsontable)

ui <- navbarPage(
  title = 'TestApp',
  selected = 'TestPage',
  theme = bs_theme(),
  nav_panel(
    title = 'TestPage',
    grid_container(
      layout = c('TestArea'),
      grid_card(
        area = 'TestArea',
        card_body(
          rHandsontableOutput("setup_hot", width = '100%')
        )
      )
    )
  )
)

server <- function(input, output, session) {
  output$setup_hot <- renderRHandsontable({
    df <- data.frame(id = 1, gender = 'Male')

    rhandsontable(df, stretchH = 'all', overflow = 'visible') %>%
      hot_col(col = 'gender', type = 'dropdown', source = c('Male', 'Female'), strict = T)
  })
}

shinyApp(ui, server)

I found that by specifying a height in the rhandsontable function I can stop the expansion, but I want the card_body to expand if more rows are added to the table. I also noticed that if stretchH = 'all' is removed, then it doesn't infinitely expand like before, but it does still expand a bit each time I open and collapse the drop down.

Any ideas for how to resolve this?

0

There are 0 best solutions below