TagBox: Keeping click order when maxDisplayTag enabled and showMultiTagOnly disabled (T1328498)#33638
TagBox: Keeping click order when maxDisplayTag enabled and showMultiTagOnly disabled (T1328498)#33638vorobey wants to merge 11 commits into
Conversation
There was a problem hiding this comment.
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
maxDisplayedTagsis used withshowMultiTagOnly: false. - Updated TagBox internal tag rendering to reorder the tag render list based on the current
valueorder (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. |
| } | ||
|
|
||
| _shouldUseClickOrderForTags(values): boolean { | ||
| return !this.option('showMultiTagOnly') |
There was a problem hiding this comment.
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.
|
|
||
| if (this._selectedItems.length === this._valuesToUpdate.length) { | ||
| this._tagsToRender = this._selectedItems; | ||
| this._tagsToRender = this._sortSelectedItemsByValues( |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
_selectedItems is using in several places, i decided not affect them in my first request
| 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) { |
| 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) { |
| })); | ||
|
No newline at end of file |
| 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) { |
| } | ||
|
|
||
| _sortSelectedItemsByValues( | ||
| selectedItems: TagBox['_selectedItems'], |
There was a problem hiding this comment.
Let's remove all references of TagBox['property'] for clarity and just use Array<string | number | any> from .d.ts types.
…agOnly disabled (T1328498)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Andrey Vorobev <dobriy.kaa@gmail.com>
| 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; |
No description provided.