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

[Bug]: it's not possible to clear dropdown_input #458

Closed
1 task done
TymekDev opened this issue Mar 19, 2024 · 0 comments · Fixed by #459
Closed
1 task done

[Bug]: it's not possible to clear dropdown_input #458

TymekDev opened this issue Mar 19, 2024 · 0 comments · Fixed by #459
Assignees
Labels

Comments

@TymekDev
Copy link
Contributor

TymekDev commented Mar 19, 2024

Guidelines

  • I agree to follow this project's Contributing Guidelines.

Project Version

No response

Platform and OS Version

No response

Existing Issues

No response

What happened?

The update_dropdown_input function is not capable of resetting a dropdown_input component back to its default value (if it had no initial selection).

Providing selected = "" or selected = character(0) to shiny::updateSelectInput clears the selection (if it had a placeholder provided).

Steps to reproduce

Steps

  1. Create dropdown_input without a default value
  2. Select a value
  3. Try updating the dropdown to clear the selected value

Example

library(shiny)
library(shiny.semantic)

ui <- semanticPage(
  dropdown_input("dropdown", LETTERS[1:5]),
  actionButton("clear", "Clear")
)

server <- function(input, output, session) {
  try_clearing <- function(value) {
    print(value)
    before <- input$dropdown
    update_dropdown_input(session, "dropdown", value = NA)
    after <- input$dropdown
    print(paste("before:", before, "|", "after:", after))
  }

  observeEvent(input$clear, {
    try_clearing(NA)
    try_clearing(NA_character_)
    try_clearing(NULL)
    try_clearing("")
    try_clearing(character(0))
  })
}

shinyApp(ui, server)

Expected behavior

I expected the dropdown_input to be reverted to its original state: no value selected.

Attachments

No response

Screenshots or Videos

No response

Additional Information

No response

@TymekDev TymekDev added the bug label Mar 19, 2024
@TymekDev TymekDev self-assigned this Mar 19, 2024
@TymekDev TymekDev mentioned this issue Mar 22, 2024
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant