dreamRs / shinyWidgets

shinyWidgets : Extend widgets available in shiny
https://dreamrs.github.io/shinyWidgets/
GNU General Public License v3.0
834 stars 153 forks source link

`airDatepickerInput()` Clear button does not clear the blue highlighting #703

Open shahreyar-abeer opened 2 months ago

shahreyar-abeer commented 2 months ago

Hi @pvictor

Great package! I have encountered an issue with the airDatepickerInput(), when the 'Clear' button is clicked, the blue highlighting is not removed. (See attached .gif)

I have solved the issue with some JS. Here is the solution

library(shiny)
library(shinyWidgets)

ui <- fluidPage(
  tags$head(
    tags$script(
      '$(document).on("shiny:bound", function(e) {
        console.log(e.target.id)
        if (e.target.id === "multiple") {
          $(".air-datepicker-button span:contains(\'Clear\')").parent().on(\'click\', function() {
            $(".-in-range-").each(function(i, cell) {$(cell).removeClass(\'-in-range-\')})
          })
        }
      })'
    )
  ),
  airDatepickerInput(
    inputId = "multiple",
    label = "Select multiple dates:",
    placeholder = "You can pick a range of dates",
    range = TRUE, clearButton = TRUE, inline = TRUE
  ),
  verbatimTextOutput("res")
)

server <- function(input, output, session) {
  output$res <- renderPrint(input$multiple)
}

shinyApp(ui, server)

}

airDatePicker-issue

pvictor commented 2 months ago

Hello, Thanks for reporting the issue and for providing a solution, I'll wait to see if the javascript library is updated.

Victor