Skip to content

TagBox: Keeping click order when maxDisplayTag enabled and showMultiTagOnly disabled (T1328498)#33638

Open
vorobey wants to merge 11 commits into
DevExpress:26_1from
vorobey:26_1_T1328498
Open

TagBox: Keeping click order when maxDisplayTag enabled and showMultiTagOnly disabled (T1328498)#33638
vorobey wants to merge 11 commits into
DevExpress:26_1from
vorobey:26_1_T1328498

Conversation

@vorobey
Copy link
Copy Markdown

@vorobey vorobey commented May 19, 2026

No description provided.

@vorobey vorobey self-assigned this May 19, 2026
@r-farkhutdinov r-farkhutdinov changed the title TagBox: Keeping click order when maxDisplayTag enabled and showMultiT… TagBox: Keeping click order when maxDisplayTag enabled and showMultiTagOnly disabled (T1328498) May 19, 2026
@vorobey vorobey marked this pull request as ready for review May 20, 2026 10:27
@vorobey vorobey requested a review from a team as a code owner May 20, 2026 10:27
Copilot AI review requested due to automatic review settings May 20, 2026 10:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses TagBox tag rendering order so that when maxDisplayedTags is exceeded and showMultiTagOnly is false, the “leading” (visible) tag reflects the user’s selection (click) order rather than the items’ natural order.

Changes:

  • Added QUnit coverage to validate leading-tag click-order behavior when maxDisplayedTags is used with showMultiTagOnly: false.
  • Updated TagBox internal tag rendering to reorder the tag render list based on the current value order (click order) in the “plain items” rendering path.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/tagBox.tests.js Adds new tests asserting the leading tag matches selection click order when multi-tag overflow is active and showMultiTagOnly is disabled.
packages/devextreme/js/__internal/ui/m_tag_box.ts Sorts _tagsToRender according to the value array order when rendering from plain items under specific multi-tag conditions.

Comment thread packages/devextreme/js/__internal/ui/m_tag_box.ts Outdated
Comment thread packages/devextreme/js/__internal/ui/m_tag_box.ts Outdated
}

_shouldUseClickOrderForTags(values): boolean {
return !this.option('showMultiTagOnly')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Replace all this.option('value') calls to be const { value } = this.option();

This is required for correct types of values as this.option('value')'s type is Properties.

Comment thread packages/devextreme/js/__internal/ui/m_tag_box.ts Outdated
Comment thread packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/tagBox.tests.js Outdated
Comment thread packages/devextreme/js/__internal/ui/m_tag_box.ts Outdated

if (this._selectedItems.length === this._valuesToUpdate.length) {
this._tagsToRender = this._selectedItems;
this._tagsToRender = this._sortSelectedItemsByValues(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The fix only affects rendering the items, but not storing. So, _tagsToRender and _selectedItems will be inconsistent. Consider updating the storing order as well (if possible).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

_selectedItems is using in several places, i decided not affect them in my first request

Comment thread packages/devextreme/js/__internal/ui/m_tag_box.ts
Copilot AI review requested due to automatic review settings May 20, 2026 13:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/tagBox.tests.js Outdated
assert.strictEqual($tagBox.find('.' + TAGBOX_TAG_CLASS).first().text(), '10', 'leading tag has correct text');
});

QUnit.test('TagBox should work correct with string ID\'s in item when valueExpr is used', function(assert) {
Copilot AI review requested due to automatic review settings May 20, 2026 13:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

assert.strictEqual($tagBox.find('.' + TAGBOX_TAG_CLASS).first().text(), '10', 'leading tag has correct text');
});

QUnit.test('TagBox should work correctly with string ID\'s in item when valueExpr is used', function(assert) {
Comment thread packages/devextreme/js/__internal/ui/m_tag_box.ts Outdated
Comment thread packages/devextreme/playground/index.ts Outdated
Comment on lines +32 to +33
}));

No newline at end of file
Copilot AI review requested due to automatic review settings May 20, 2026 13:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

assert.strictEqual($tagBox.find('.' + TAGBOX_TAG_CLASS).first().text(), '10', 'leading tag has correct text');
});

QUnit.test('TagBox should work correctly with string ID\'s in item when valueExpr is used', function(assert) {
Comment thread packages/devextreme/js/__internal/ui/m_tag_box.ts Outdated
}

_sortSelectedItemsByValues(
selectedItems: TagBox['_selectedItems'],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's remove all references of TagBox['property'] for clarity and just use Array<string | number | any> from .d.ts types.

vorobey and others added 3 commits May 20, 2026 18:00
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Andrey Vorobev <dobriy.kaa@gmail.com>
Copilot AI review requested due to automatic review settings May 20, 2026 15:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

assert.strictEqual($tagBox.find('.' + TAGBOX_TAG_CLASS).first().text(), '10', 'leading tag has correct text');
});

QUnit.test('TagBox should work correctly with string ID\'s in item when valueExpr is used', function(assert) {
return (a || b) && !(a && b);
}

type TagBoxItem = string | number | any;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants