簡體   English   中英

具有長名稱的閃亮 selectInput/pickerInput 應該溢出側邊欄

[英]Shiny selectInput/pickerInput with long names should overflow sidebar

我想在側邊欄布局中使用bs4Dash構建一個閃亮的應用程序。 側邊欄包含一個下拉選擇菜單,其中包含具有長名稱的項目。 打開下拉菜單后,我希望可以看到完整的項目名稱,即溢出儀表板的主體。 默認情況下,名稱在側邊欄邊框處被剪切 ( shiny::selectizeInput ),或者下拉內容與側邊欄邊框右對齊,並且項目名稱的開頭在屏幕外左側 ( shinyWidgets::pickerInput )。

這是應用程序的外觀(更新於 2022-12-16):

打開 pickerInput 的應用程序

打開 selectInput 的應用程序

我嘗試將解決方案應用於此處描述的flexdashboard ,但無法使其正常工作。

謝謝你的幫助!

這是我的應用程序的可重現示例:

# app.R
library(shiny)
library(bs4Dash)
library(shinyWidgets)

vec_long_items <- sapply(1:10, function(i) {
  paste("START", paste(sample(letters, 100, replace = TRUE), collapse = ""))
})

shinyApp(
  ui = dashboardPage(
    header = bs4DashNavbar(
      title = "Long items to select", disable = TRUE, controlbarIcon = NULL
    ),
    sidebar = bs4DashSidebar(
      skin = "white",
      shinyWidgets::pickerInput(
        inputId = "in1", label = "shinyWidgets::pickerInput", choices = vec_long_items
      ),
      shiny::selectInput(
        inputId = "in2", label = "shiny::selectInput", choices = vec_long_items
      )
    ),
    body = dashboardBody(tableOutput("out_text"))
  ),
  server = function(input, output, session) {
    output$out_text <- renderTable(data.frame(items = vec_long_items))
  },
  options = list(launch.browser = FALSE)
)

我的會話信息():

R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)  
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
[1] LC_COLLATE=German_Switzerland.1252  LC_CTYPE=German_Switzerland.1252    LC_MONETARY=German_Switzerland.1252 LC_NUMERIC=C                        LC_TIME=German_Switzerland.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] bs4Dash_2.1.0 shiny_1.7.2

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.7         shinyWidgets_0.7.5 digest_0.6.29      later_1.3.0        mime_0.12          R6_2.5.1           lifecycle_1.0.2    xtable_1.8-4       jsonlite_1.8.0     magrittr_2.0.3
[11] cachem_1.0.6       rlang_1.0.5        cli_3.4.0          fontawesome_0.3.0  promises_1.2.0.1   jquerylib_0.1.4    bslib_0.4.0        ellipsis_0.3.2     tools_4.1.0        httpuv_1.6.5
[21] fastmap_1.1.0      compiler_4.1.0     memoise_2.0.1      htmltools_0.5.2    sass_0.4.2

試試這個CSS:

css <- ".main-sidebar, .main-sidebar .sidebar .os-viewport, .os-host-overflow, .os-host-overflow>.os-padding {overflow: visible !important;}"

IE

    body = dashboardBody(
      tags$head(
        tags$style(HTML(css))
      ),

      shinyWidgets::pickerInput(
        inputId = "in1", label = "shinyWidgets::pickerInput", choices = vec_long_items, 
        options = pickerOptions(dropdownAlignRight = TRUE)
      ),

我為 pickerInput 找到了一個 CSS 屬性,可以改進輸出。 改變身體如下:

# ...
body = dashboardBody(
      tags$head(
        tags$style(HTML("
        .dropdown-menu.show {
          display: contents;
        }
      "))
      ),
      tableOutput("out_text")
    )
# ...

現在有一個滾動條可以查看完整的元素。 不是我想要的,但已經更好了。

具有 dropdown-x-scrollbar 的 pickerInput 應用程序

我仍在尋找“溢出解決方案”:-)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM