Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dropdownBlock icon not working #8

Closed
scottyraymond opened this issue Aug 5, 2018 · 5 comments
Closed

dropdownBlock icon not working #8

scottyraymond opened this issue Aug 5, 2018 · 5 comments

Comments

@scottyraymond
Copy link

Good Day,

I am using shinydashboardPlus 0.6.0.9000 and I came across a minor error in the generated HTML today. For dropdownBlock elements, I couldn't figure out why the icons were not showing up. After inspecting the HTML I can see that the automatic HTML generation may need to be updated, as it is not handling the icon properly.

Please see below for the HTML extracted from the Google Chrome inspector.

<li class="dropdown" id="mydropdown">
  <a href="#" class="dropdown-toggle" data-toggle="dropdown">
    <!-- Note the <i class="fa fa-sliders"></i>" -->
    <i class="fa fa-<i class="fa fa-sliders"></i>"></i>
    Dropdown 1
    <!-- Would be good to ensure documentations shows 'label' as a property  -->
    <span class="label label-danger">2</span>
  </a>
  <ul class="dropdown-menu" style="left: 0; right: auto;"> ... </ul>
</li>

Another item would be to ensure the the help documentation includes mentions of 'label' and 'badgeStatus' properties.

Thanks.
Scott

@DivadNojnarg
Copy link
Member

DivadNojnarg commented Aug 10, 2018

Hi @scottyraymond ,

can you send me the R code that produces this error?

Thanks

David

@scottyraymond
Copy link
Author

Hi David,

Sorry I didn't get back to your message yet... I've been busy writing R code! I see that the issue is closed, but for your records, this is some code that will reproduce the error.

ui <- dashboardPagePlus(
header = dashboardHeaderPlus(
title = "My Application",
enable_rightsidebar = TRUE,
rightSidebarIcon = "filter",
left_menu = tagList(
dropdownBlock(
id = "selector_1", icon = icon("sliders"), title = "SELECTOR 1", label = NULL, badgeStatus = NULL
)
)
),
sidebar = dashboardSidebar(),
rightsidebar = rightSidebar(),
body = dashboardBody()
)
server <- function(input, output, session) { }
shinyApp(ui,server)

@Mad-Ram
Copy link

Mad-Ram commented Mar 25, 2019

I ran into the same issue as well. Code that reproduces error:

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)

ui <- dashboardPagePlus(
  collapse_sidebar = TRUE
  ,dashboardHeaderPlus(
    fixed = FALSE
    ,enable_rightsidebar = FALSE
    ,left_menu = tagList(
      dropdownBlock(
        id = "upload"
        ,icon = icon("file-upload") # this font-awesome icon doesn't show up
        ,title = "Upload files"
        ,badgeStatus = NULL
        ,fileInput(
          "upload"
          ,"upload a file"
        )
      )
    )
  )
  ,dashboardSidebar(disable = TRUE)
  ,dashboardBody(
    setShadow(class = "dropdown-menu")
    ,uiOutput('box_1')
  )
  ,rightsidebar = rightSidebar()
)

server <- function(input, output){
}

shinyApp(ui = ui, server = server)

@DivadNojnarg
Copy link
Member

Please use icon = "file-upload" instead of icon = icon("file-upload"):

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)

ui <- dashboardPagePlus(
  collapse_sidebar = TRUE,
  dashboardHeaderPlus(
    fixed = FALSE,
    enable_rightsidebar = FALSE,
    left_menu = tagList(
      dropdownBlock(
        id = "upload",
        icon = "file-upload",
        title = "Upload files",
        badgeStatus = NULL,
        fileInput("upload","upload a file")
      )
    )
  ),
  dashboardSidebar(disable = TRUE),
  dashboardBody(uiOutput('box_1')),
  rightsidebar = rightSidebar()
)

server <- function(input, output){
}

shinyApp(ui = ui, server = server)

It is a bit different from shiny that uses the icon function allowing either fontAwesome or glyph icons... I still have to decide whether to keep icon or just the icon name since it it misleading for users.

@Mad-Ram
Copy link

Mad-Ram commented Mar 26, 2019

Awesome, using icon = "upload" works.

icon = "file-upload" didn't work, but I assume it's because the package doesn't include the most recent version of font-awesome.

Two non-invasive ideas to keep it as is but avoid misleading users is:

  1. Add to the ?dropdownUpload documentation that the icon parameter must be type string (not icon('string') like other shiny functions)
  2. Or add a check if the icon parameter is type string, and if it's not then throw an error like "icon input must be of type string".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants