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

458 dropdown clear #459

Merged
merged 8 commits into from Apr 4, 2024
Merged

458 dropdown clear #459

merged 8 commits into from Apr 4, 2024

Conversation

TymekDev
Copy link
Contributor

@TymekDev TymekDev commented Mar 22, 2024

Prior to this change only multi-selection dropdown could be cleared. This change makes update_dropdown_input behavior analogous to shiny::updateSelectInput.

Note: this is a breaking change. Prior to this commit updating with character(0) or "" did not have any effect.

Closes #458

DoD

  • Major project work has a corresponding task. If there’s no task for what you are doing, create it. Each task needs to be well defined and described.
  • Change has been tested (manually or with automated tests), everything runs correctly and works as expected. No existing functionality is broken.
  • No new error or warning messages are introduced.
  • All interaction with a semantic functions, examples and docs are written from the perspective of the person using or receiving it. They are understandable and helpful to this person.
  • If the change affects code or repo structure, README, documentation and code comments should be updated.
  • All code has been peer-reviewed before merging into any main branch.
  • All changes have been merged into the main branch we use for development (develop).
  • Continuous integration checks (linter, unit tests) are configured and passed.
  • Unit tests added for all new or changed logic.
  • All task requirements satisfied. The reviewer is responsible to verify each aspect of the task.
  • Any added or touched code follows our style-guide. The entire codebase could be run through a formatter, so I didn't update this single file.

@TymekDev TymekDev force-pushed the 458-dropdown-clear branch 2 times, most recently from dc3e8bc to 23c37a2 Compare March 22, 2024 19:53
Copy link
Member

@jakubnowicki jakubnowicki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR breaks the update of dropdown choices:

library(shiny)
library(shiny.semantic)

ui <- semanticPage(
  dropdown_input("simple_dropdown", LETTERS[1:5]),
  actionButton("simple_button", "Update input to use all letters"),
)


server <- shinyServer(function(input, output, session) {
  observeEvent(input$simple_button, {
    update_dropdown_input(session, "simple_dropdown", choices = LETTERS)
  })
})

shinyApp(ui = ui, server = server)

Prior to this change only multi-selection dropdown could be cleared.
This change makes `update_dropdown_input` behavior analogous to
`shiny::updateSelectInput`.

Note: this is a breaking change. Prior to this commit updating with
`character(0)` or `""` did not have any effect.
@TymekDev
Copy link
Contributor Author

TymekDev commented Mar 25, 2024

@jakubnowicki fixed 👌 options variable had me fooled

R/dropdown.R Outdated Show resolved Hide resolved
Expected `update_dropdown_input` behavior:
- choices != NULL and value == NULL changes choices and clears selection
- choices != NULL and value != NULL changes choices and sets selection
- value == "" and value == character(0) clear the dropdown
- Providing a value not present in choices doesn't change the selection

The behavior is uniform between a single-selection and a multi-selection
variants.

Note:
- an empty single-selection `dropdown_input` returns "" (no changes)
- an empty multi-selection `dropdown_input` returns NULL (no changes)
Copy link
Member

@jakubnowicki jakubnowicki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jakubnowicki jakubnowicki merged commit 6fc2ab5 into develop Apr 4, 2024
5 checks passed
@jakubnowicki jakubnowicki deleted the 458-dropdown-clear branch April 4, 2024 08:53
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

Successfully merging this pull request may close these issues.

[Bug]: it's not possible to clear dropdown_input
2 participants