Fix updateSelectizeInput(), fixes #2624 #2625
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes #2624 by aligning the choice processing behavior of
selectizeInput()
/selectInput()
andupdateSelectizeInput()
/updateSelectInput()
.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 ofupdateSelectizeInput()
, because its choice processing implementation considered them groups, just like the originalchoicesWithNames()
code did before I rewrote it.isGroup()
to include lists and added a test.isGroup()
to also include them and added tests.asNamed()
inprocessGroupedChoices()
to ensuremapply()
would work; the function inside is what produces the correct error. I added tests for this.NA
andNULL
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 selectserver = TRUE
specifically for performance reasons aschoices
is large.In order to compete with the existing
updateSelectizeInput()
code,choicesWithNamesRectangle()
would have needed to be rewritten as a single pass ofchoices
, 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()
.