Navigation Menu

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

Fix updateSelectizeInput(), fixes #2624 #2625

Merged
merged 1 commit into from Sep 20, 2019
Merged

Conversation

alandipert
Copy link
Contributor

@alandipert alandipert commented Sep 19, 2019

This PR fixes #2624 by aligning the choice processing behavior of selectizeInput()/selectInput() and updateSelectizeInput()/updateSelectInput().

  • In previous releases of Shiny, named choices of length 1 that were unnamed lists were considered groups, not leaves. list(x=list(123)) is an example. My changes in Fix selectInput/selectizeInput handling character(1) options #2540 altered that behavior so unnamed lists of length 1 were considered leaves, not groups. The bug was revealed during testing of updateSelectizeInput(), because its choice processing implementation considered them groups, just like the original choicesWithNames() code did before I rewrote it.
    • To fix this, I changed the definition of isGroup() to include lists and added a test.
  • I noticed that empty lists and vectors were considered leaves and not groups. I modified isGroup() to also include them and added tests.
  • I noticed that lists containing unnamed groups would result in a different error than the previous code produced. I added an asNamed() in processGroupedChoices() to ensure mapply() would work; the function inside is what produces the correct error. I added tests for this.
  • I noticed that a few special cases of NA and NULL were untested. I added tests.

Notes

Note that a previous iteration of this PR included a replacement for updateSelectizeInput()'s choice processing code that built on #2540 instead of implementing choice processing separately.

Unfortunately, that code necessitated 2 walks of the choices tree, and so was twice as slow. We are highly sensitive to performance in this case as users select server = TRUE specifically for performance reasons as choices is large.

In order to compete with the existing updateSelectizeInput() code, choicesWithNamesRectangle() would have needed to be rewritten as a single pass of choices, which we deemed too significant an undertaking given the urgency of a 1.4.0 release.

So, instead of doing that, we reduced the scope of this PR to a small change of the new code and the addition of tests that bring it to feature parity with the code inside updateSelectizeInput().

@alandipert alandipert changed the title Fix updateSelectizeInput(), fixes #2540 Fix updateSelectizeInput(), fixes #2624 Sep 19, 2019
@jcheng5 jcheng5 requested review from wch and removed request for jcheng5 September 19, 2019 15:24
@alandipert alandipert marked this pull request as ready for review September 19, 2019 17:02
NEWS.md Outdated Show resolved Hide resolved
@wch
Copy link
Collaborator

wch commented Sep 19, 2019

This PR should be targeted toward the rc-v1.40 branch instead of master.

@alandipert alandipert changed the base branch from master to rc-v1.4.0 September 19, 2019 17:22
@alandipert alandipert force-pushed the fix-selectize-update branch 2 times, most recently from 8fa4f43 to ccd31b0 Compare September 19, 2019 18:56
NEWS.md Outdated
@@ -26,7 +26,7 @@ shiny 1.4.0

* Added `resourcePaths()` and `removeResourcePaths()` functions. ([#2459](https://github.com/rstudio/shiny/pull/2459))

* Resolved [#2515](https://github.com/rstudio/shiny/issues/2515): `selectInput()` now deals appropriately with named factors. ([#2524](https://github.com/rstudio/shiny/pull/2524))
* Resolved [#2515](https://github.com/rstudio/shiny/issues/2515): `selectInput()` and `selectizeInput()` now deal appropriately with named factors. Note that `updateSelectInput()` and `updateSelectizeInput()` **do not** yet handle factors; their behavior is unchanged. ([#2525](https://github.com/rstudio/shiny/pull/2525))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oops, this should reference 2524 and 2625.

@alandipert alandipert merged commit 8d14e7a into rc-v1.4.0 Sep 20, 2019
@alandipert alandipert deleted the fix-selectize-update branch September 20, 2019 19:35
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.

None yet

2 participants