fix(conditionalPanel): Coerce condition result to boolean #4127
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.
Fixes #4126
The key fix here is to force the result of
condFunc()
to be boolean so that it can be correctly compared with the current state of theconditionalPanel()
.condFunc()
is created byscopeExprToFunc()
which was previously typed as returning aboolean
value. In practice, however, this function returns anunknown
value depending on the user expression.scopeExprToFunc()
is sufficiently general to be useful in other places, so I relaxed the type fromboolean
tounknown
(rather than doing the boolean coercion before returning). This also then gives a hint to users ofcondFunc()
that they should verify the return value.