Tests and tweaks to the select menu widget #1019
Open
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.
There are now tests for the no-values, one-value, and multiple-values case in multiple select mode.
Also improved / refactored some implementation details. @gordonwoodhull, as per your suggestions I changed the implementation of
_chart.onChange
to always callreplaceFilter
with an array containing the array of filters reflecting the current selections. This works for both the single and multiple select mode.Additionally the empty option (prompt option) is always filtered out, so when the prompt option is the only one selected, then the array will be empty, i.e. the select is re-set.
The demo under
web/examples/select.html
was very helpful :) I was wondering about was the behavior in multiple mode where the prompt option can be selected along with other options. Would the correct / expected behavior here be to override and deselect everything when that option is selected?In any case, the actual
onChange
callback's only responsibility is now to forward the selected options from the DOM element (and sort out browser differences). This also seems to make the_chart.onChange
method more testable since one can easily call the method with different combinations of selections. I've left in the option to sendnull
into_chart.onChange
, which is mostly a convenience in tests, but maybe confusing. Let me know if I should remove it.