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
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2155dcd
Work-in-progress: integration test: multiple selection and clearing o…
jayaddison Mar 9, 2023
796e48d
integration test: multiple selection and clearing of grouped options:…
jayaddison Mar 30, 2023
6916eae
integration test: multiple selection and clearing of grouped options:…
jayaddison Mar 30, 2023
3fd4534
integration test: multiple selection and clearing of grouped options:…
jayaddison Mar 30, 2023
50ab561
integration test: multiple selection and clearing of grouped options:…
jayaddison Mar 30, 2023
db929cb
integration test: multiple selection and clearing of grouped options:…
jayaddison Mar 30, 2023
4ec3c04
integration test: multiple selection and clearing of grouped options:…
jayaddison Apr 3, 2023
1615298
integration test: multiple selection and clearing of grouped options:…
jayaddison Apr 3, 2023
5ae5078
integration test: multiple selection and clearing of grouped options:…
jayaddison Apr 3, 2023
760a544
integration test: multiple selection and clearing of grouped options:…
jayaddison Apr 3, 2023
0037113
integration test: multiple selection and clearing of grouped options:…
jayaddison Apr 3, 2023
0de7cd0
integration test: multiple selection and clearing of grouped options:…
jayaddison Apr 3, 2023
c80c331
Revert "Revert "Unselect events: cache lookup key fix (#6179)" (#6217)"
jayaddison Apr 3, 2023
24589c1
cleanup: remove temporary file accidentally added with commit 760a544…
jayaddison Apr 3, 2023
29f20dd
Revert "Revert "Revert "Unselect events: cache lookup key fix (#6179)…
jayaddison Apr 3, 2023
5506e72
Fix: convert grouped option identifiers to the 'string' type
jayaddison Apr 3, 2023
4a6f302
Fix: normalize data.children contents recursively within _normalizeIt…
jayaddison Apr 4, 2023
54197a9
linting: reduce line length to within limits by using 'this' variable…
jayaddison Apr 4, 2023
9a1e969
Revert "linting: reduce line length to within limits by using 'this' …
jayaddison Apr 4, 2023
afb60c8
linting: reduce line length to within limits by moving recursive _nor…
jayaddison Apr 4, 2023
758a717
spec alignment: HTML optgroup elements cannot be nested, so the data …
jayaddison Apr 4, 2023
cbf3295
Revert "spec alignment: HTML optgroup elements cannot be nested, so t…
jayaddison Apr 4, 2023
779726c
Merge branch 'select2:develop' into issue-3882/unselection-for-multip…
jayaddison Feb 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/js/select2/data/select.js
Expand Up @@ -278,6 +278,10 @@ define([
item._resultId = this.generateResultId(this.container, item);
}

if (item.children) {
item.children = item.children.map(this._normalizeItem);
jayaddison marked this conversation as resolved.
Show resolved Hide resolved
}

return $.extend({}, defaults, item);
};

Expand Down
61 changes: 61 additions & 0 deletions tests/integration/select2-methods.js
Expand Up @@ -137,3 +137,64 @@ test('multiple value matches the jquery value', function (assert) {
'The values should match the jquery values'
);
});

test('multiple selection and clearing of grouped options', function (assert) {
var $container = $('#qunit-fixture');
var $select = $('<select></select>');
$container.append($select);

var data = [{
text: 'Group 1',
children: [{
id: 1,
text: 'Option 1.1'
}, {
id: 2,
text: 'Option 1.2'
}]
}, {
text: 'Group 2',
children: [{
id: 3,
text: 'Option 2.1'
}, {
id: 4,
text: 'Option 2.2'
}]
}];

var select = new Select2($select, {
multiple: true,
data: data
});

$select.val(['3', '1']);
$select.trigger('change');

assert.equal(
$select.find(':selected').length,
2,
'Two items should be selected'
);

// Remove the first item
$container.find('.select2-selection__choice__remove').trigger('click');

var $selections = $('.select2-selection__choice');
assert.equal(
$selections.length,
1,
'One item should remain selected'
);

// Open the dropdown menu
select.selection.trigger('query', {term: 'Option'});

// Remove the second selection by clicking on the item in the dropdown
$('.select2-results__option[aria-selected=true]').trigger('mouseup');

assert.notOk(
$select.find(':selected').length,
'No items should be selected'
);
});