select2 icon indicating copy to clipboard operation
select2 copied to clipboard

Fixup: convert optgroup child data identifiers to string datatype

Open jayaddison opened this issue 2 years ago • 5 comments

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.

jayaddison avatar Mar 30 '23 16:03 jayaddison

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..

jayaddison avatar Mar 30 '23 17:03 jayaddison

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.

jayaddison avatar Apr 03 '23 19:04 jayaddison

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.

kevin-brown avatar Apr 04 '23 03:04 kevin-brown

Yep, that sounds sensible - I'll take another look at the code and see how to refactor it like that.

jayaddison avatar Apr 04 '23 08:04 jayaddison

(I guess that's not really refactoring; more like a better fix. anyway, taking a look into that now)

jayaddison avatar Apr 04 '23 08:04 jayaddison