Skip to content

Commit f42adde

Browse files
Ruslan FarkhutdinovRuslan Farkhutdinov
andauthored
TagBox: Multitag should be rendered if maxDisplayedTags and fieldTemplate is specified (T1303488) (DevExpress#30713)
Co-authored-by: Ruslan Farkhutdinov <ruslan.farkhutdinov@devexpress.com>
1 parent e2b0038 commit f42adde

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

packages/devextreme/js/__internal/ui/m_tag_box.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,10 +1074,10 @@ class TagBox<
10741074
// @ts-expect-error ts-error
10751075
this.option('selectedItems', this._selectedItems.slice());
10761076
}
1077-
this._cleanTags();
10781077

10791078
const fieldTemplate = this._getFieldTemplate();
10801079
if (!fieldTemplate) {
1080+
this._cleanTags();
10811081
this._renderTagsCore();
10821082
}
10831083
}

packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/tagBox.tests.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8160,6 +8160,32 @@ QUnit.module('regression', {
81608160

81618161
assert.strictEqual(selectAllCheckBox.option('value'), true, 'the "select all" checkbox is checked');
81628162
});
8163+
8164+
QUnit.test('Multitag should be rendered if maxDisplayedTags and fieldTemplate is specified (T1303488)', function(assert) {
8165+
const items = [
8166+
{ id: 1, name: 'Item 1' },
8167+
{ id: 2, name: 'Item 2' },
8168+
];
8169+
8170+
const selectedItems = [1, 2];
8171+
8172+
const fieldTemplate = (data) => {
8173+
return $('<div>').dxTextBox({ value: data.name });
8174+
};
8175+
8176+
const $tagBox = $('#tagBox').dxTagBox({
8177+
items: items,
8178+
value: selectedItems,
8179+
displayExpr: 'name',
8180+
valueExpr: 'id',
8181+
maxDisplayedTags: 1,
8182+
fieldTemplate
8183+
});
8184+
8185+
const $tag = $tagBox.find(`.${TAGBOX_TAG_CLASS}`);
8186+
8187+
assert.strictEqual($tag.length, 1, 'only one tag is rendered');
8188+
});
81638189
});
81648190

81658191
QUnit.module('valueChanged should receive correct event parameter', {

0 commit comments

Comments
 (0)