Skip to content

Commit 49b7a64

Browse files
r-farkhutdinovRuslan Farkhutdinov
andauthored
TagBox: Multitag should be rendered if maxDisplayedTags and fieldTemplate is specified (T1303488) (DevExpress#30714)
Co-authored-by: Ruslan Farkhutdinov <[email protected]>
1 parent 1cf2638 commit 49b7a64

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

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
@@ -8181,6 +8181,32 @@ QUnit.module('regression', {
81818181

81828182
assert.strictEqual(selectAllCheckBox.option('value'), true, 'the "select all" checkbox is checked');
81838183
});
8184+
8185+
QUnit.test('Multitag should be rendered if maxDisplayedTags and fieldTemplate is specified (T1303488)', function(assert) {
8186+
const items = [
8187+
{ id: 1, name: 'Item 1' },
8188+
{ id: 2, name: 'Item 2' },
8189+
];
8190+
8191+
const selectedItems = [1, 2];
8192+
8193+
const fieldTemplate = (data) => {
8194+
return $('<div>').dxTextBox({ value: data.name });
8195+
};
8196+
8197+
const $tagBox = $('#tagBox').dxTagBox({
8198+
items: items,
8199+
value: selectedItems,
8200+
displayExpr: 'name',
8201+
valueExpr: 'id',
8202+
maxDisplayedTags: 1,
8203+
fieldTemplate
8204+
});
8205+
8206+
const $tag = $tagBox.find(`.${TAGBOX_TAG_CLASS}`);
8207+
8208+
assert.strictEqual($tag.length, 1, 'only one tag is rendered');
8209+
});
81848210
});
81858211

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

0 commit comments

Comments
 (0)