Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixup: convert optgroup child data identifiers to string datatype #6239

Open
wants to merge 23 commits into
base: develop
Choose a base branch
from

Conversation

jayaddison
Copy link
Contributor

@jayaddison jayaddison commented Mar 30, 2023

This pull request includes

  • Bug fix

The following changes were made

Resolves #3882.

@jayaddison
Copy link
Contributor Author

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

… logic adjustment: attempt to de-select the second item using the dropdown menu
… fixup: variable declaration should be explicit
… filter selected items by aria-selected property instead of highlight CSS class (that doesn't always imply selection)
);

// Remove the second selection by clicking on the item in the dropdown
$selections.first().trigger('click');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea with this line is to simulate the user clicking on the dropdown menu item, so that we can check that the selection is removed afterwards. It doesn't appear to invoke a relevant event handler though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the event from click to mouseup -- to correspond with the event handler here seems to make a difference. It causes the dom-changes.js integration test to break, though:

>> select2(val) - multiple selection and clearing of grouped options
>> Message: Too many calls to the `assert.async` callback
>> Actual: null
>> Expected: undefined
>> http://localhost:9999/tests/integration/dom-changes.js:284:14

… use the qunit fixture as the select2 element's container
… update the mid-test 'choices remaining' jQuery query to be fixture-bounded
… relocate the code that opens the select2 element's dropdown menu
… open the dropdown menu by performing a select2 search
… use the (globally-scoped) dropdown menu results to de-select the last selected item
@jayaddison
Copy link
Contributor Author

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 jayaddison changed the title Test coverage: unselection for multiple select with option groups Fixup: convert optgroup child data identifiers to string datatype Apr 3, 2023
@kevin-brown
Copy link
Member

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.

@jayaddison
Copy link
Contributor Author

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

@jayaddison
Copy link
Contributor Author

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

jayaddison and others added 3 commits April 4, 2023 10:46
…provided to a select2 constructor should not contain multiple levels of child nesting; limit normalizeItem recursion to depth one as a result
…he data provided to a select2 constructor should not contain multiple levels of child nesting; limit normalizeItem recursion to depth one as a result"

This reverts commit 758a717.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot deselect items in grouped multiple select when data ids are not strings
2 participants