select2
select2 copied to clipboard
Fixup: convert optgroup child data identifiers to string datatype
This pull request includes
- [x] Bug fix
The following changes were made
- Add a unit test case intended to cover behaviour initially reported in #3882.
- Ensure that optgroup (children) data identifiers are converted to
string.
Resolves #3882.
Argh, I don't think this is testing the correct behaviour.
Currently the code here tests clicks on the 'remove' button on each tag within the multi-select.
Re-attempting the demo from #3882, that behaviour works fine. What is buggy is selecting an item from the drop-down, and then attempting to de-select it, but again by using the dropdown.
Hopefully that is a small change to the test code..
Ok, the test coverage here for #3882 seems to also validate the fix attempted originally in #6179 (subsequently reverted due to lack of test coverage).
Even so: I don't think that the fix from #6179 is ideal. There could be a better approach possible. I'll spend some time to investigate that while looking at this.
I'm wondering if it would make sense to apply this fix within SelectAdapter._normalizeItem, likely by calling _normalizeItem on all of the children recursively if data.children is present (something I didn't realize we didn't do). I suspect that might allow this to be applied a little more consistently, so it works even if the results dropdown has not been loaded.
Yep, that sounds sensible - I'll take another look at the code and see how to refactor it like that.
(I guess that's not really refactoring; more like a better fix. anyway, taking a look into that now)