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

TagBox: Fix tag label display when valueExpr is set to function and hideSelectedItems is enabled (T1234032) (Draft) #27521

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a96c801
Creaet Unit test
jdvictoria Jun 5, 2024
c8ad3b7
Apply fix
jdvictoria Jun 5, 2024
92018f7
Create TestCafe test
jdvictoria Jun 5, 2024
b98b679
Refactor solution and tests
jdvictoria Jun 5, 2024
f5810dc
Fix labels
jdvictoria Jun 5, 2024
10dc0f6
Fix label
jdvictoria Jun 6, 2024
9227c71
Refactor solution
jdvictoria Jun 7, 2024
875d1f5
reduce unnecessary data
jdvictoria Jun 11, 2024
dfd8a82
add runtime change test
jdvictoria Jun 11, 2024
d66f35b
refactor fix
jdvictoria Jun 11, 2024
705f6a2
Merge branch 'DevExpress:24_1' into 24_1_TagBox_T1234032
jdvictoria Jun 14, 2024
2287059
revert fix
jdvictoria Jun 14, 2024
4ab4efc
refactor tests
jdvictoria Jun 14, 2024
159d863
CI: Branch 24_2 (#27607)
alexslavr Jun 18, 2024
7af7685
revert: Fix modules relative paths after moving Demos (#27563) (#2761…
EugeniyKiyashko Jun 18, 2024
78b8425
Bump devextreme version (24.2.0) (#27608)
dxrobot Jun 18, 2024
48e042b
DataGrid - Flickering of cell focus / revert button during DataGrid u…
pomahtri Jun 18, 2024
8c3cc2c
Toolbar Adaptability: Fix demos and unskip Testcafe tests (Angular, R…
jdvictoria Jun 19, 2024
7d73240
TabPanel/Overview: Corrected classname appending in Vue template by a…
nikkithelegendarypokemonster Jun 19, 2024
3d5993e
TileView/Directions: Apply standardized width and added space between…
nikkithelegendarypokemonster Jun 19, 2024
1fce2fe
Demos: update splits in descriptions (#27621) (#27622)
vladaskorohodova Jun 19, 2024
dfe964c
Fix list drag and drop demo (#27391) (#27635)
ivanblinov2k17 Jun 20, 2024
6b303b7
Documentation - Fix - Framework dependant desriptions missing (#27610…
ivanblinov2k17 Jun 20, 2024
b78b156
Fix demo tests (#27638)
williamvinogradov Jun 20, 2024
b551c25
TestCafe testing: Merge all pages for testing into one page (#27644)
Alyar666 Jun 20, 2024
39cc654
Fix React Drawer Component 24_2 (#27634)
tomodasheesh Jun 21, 2024
293a37d
DataGrid - Dragged column from the column chooser is frozen when the …
Alyar666 Jun 21, 2024
8ffffcc
24_2 fix Vue warnings (#27624)
dxArtemiusz Jun 21, 2024
7fe1eb5
chore: try remove some SSR-related workarounds (24_2) (#27645)
VasilyStrelyaev Jun 21, 2024
f1216d6
DataGrid - Summary values in the fixed column disappear when virtual …
pomahtri Jun 21, 2024
fdf0dcb
Merge branch 'DevExpress:24_2' into 24_1_TagBox_T1234032
jdvictoria Jun 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion packages/devextreme/js/__internal/ui/m_tag_box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,15 @@ const TagBox = (SelectBox as any).inherit({
},

_shouldGetItemsFromPlain(values) {
return values && this._dataController.isLoaded() && values.length <= this._getPlainItems().length;
if (!values || !this._dataController.isLoaded()) {
return false;
}

if (this.option('hideSelectedItems')) {
return true;
}

return values.length <= this._getPlainItems().length;
},

_getItemsFromPlain(values) {
Expand All @@ -977,6 +985,10 @@ const TagBox = (SelectBox as any).inherit({
if (needFilterPlainItems) {
const plainItems = this._getPlainItems();
selectedItems = this._filterSelectedItems(plainItems, values);

if (this.option('hideSelectedItems')) {
selectedItems = (selectedItems || []).concat(this.option('selectedItems') || []);
}
}

return selectedItems;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6822,6 +6822,45 @@ QUnit.module('performance', () => {
assert.ok($.isFunction(filter), 'filter is function');
});

[false, true].forEach(changeAtRuntime => {
QUnit.test(`tag labels should be correctly displayed with valueExpr as function and hideSelectedItems enabled ${changeAtRuntime ? 'at runtime' : ''} (T1234032)`, function(assert) {
const dataSource = [
{ id: 1, scheme: 'schema 1', name: 'item1' },
{ id: 2, scheme: 'schema 2', name: 'item2' },
{ id: 3, scheme: 'schema 3', name: 'item3' },
];

const $tagBox = $('#tagBox').dxTagBox({
dataSource,
valueExpr(x) {
return x && x.name + ' ' + x.scheme;
},
displayExpr: 'name',
hideSelectedItems: !changeAtRuntime,
opened: true,
});

const tagBox = $tagBox.dxTagBox('instance');
const $list = tagBox._list.$element();

if(changeAtRuntime) {
Copy link
Contributor

Choose a reason for hiding this comment

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

[excess operation]

This condition is excess: if initially property is true, setting it to true at runtime will do nothing

tagBox.option('hideSelectedItems', true);
}

$($list.find('.dx-list-item').eq(0)).trigger('dxclick');
Copy link
Contributor

Choose a reason for hiding this comment

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

[repeatable code style mistake]

Constants please!


tagBox.open();
$($list.find('.dx-list-item').eq(0)).trigger('dxclick');

tagBox.open();
$($list.find('.dx-list-item').eq(0)).trigger('dxclick');

const $tagContainer = $tagBox.find(`.${TAGBOX_TAG_CONTAINER_CLASS}`);

assert.strictEqual($.trim($tagContainer.text()), 'item1item2item3', 'label values are displayed correctly');
});
});

QUnit.test('loadOptions.filter should be correct when user filter is also used', function(assert) {
const load = sinon.stub().returns([{ id: 1, text: 'item 1' }, { id: 2, text: 'item 2' }]);

Expand Down
Loading