From adc555e58b22ff9df8a92acfecd2eabeb9763d00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marker=20dao=20=C2=AE?= Date: Thu, 16 Apr 2026 13:41:23 +0200 Subject: [PATCH 1/2] Chat Prompt Suggestions: Support nested option path for suggestions updates --- packages/devextreme/js/__internal/ui/chat/chat.ts | 6 ++++-- .../DevExpress.ui.widgets/chatParts/chat.tests.js | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/devextreme/js/__internal/ui/chat/chat.ts b/packages/devextreme/js/__internal/ui/chat/chat.ts index 4666147a3f96..8caf6ec4bfad 100644 --- a/packages/devextreme/js/__internal/ui/chat/chat.ts +++ b/packages/devextreme/js/__internal/ui/chat/chat.ts @@ -786,9 +786,11 @@ class Chat extends Widget { this._createSendButtonAction(); this._messageBox.option(name, this._getSendButtonOptionsWithAction()); break; - case 'suggestions': - this._suggestions?.updateOptions(value as ChatProperties['suggestions']); + case 'suggestions': { + const options = Widget.getOptionsFromContainer(args); + this._suggestions?.updateOptions(options); break; + } default: super._optionChanged(args); } diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets/chatParts/chat.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets/chatParts/chat.tests.js index 460078a1d63b..541e26164c7e 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets/chatParts/chat.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets/chatParts/chat.tests.js @@ -2821,6 +2821,17 @@ QUnit.module('Chat', () => { assert.strictEqual(this.getSuggestionsElement().length, 1, 'suggestions container remains in DOM'); assert.strictEqual(this.getSuggestionItems().length, 0, 'items are removed'); }); + + QUnit.test('suggestions items should be updated via nested option path', function(assert) { + this.reinit({ + suggestions: { items: [{ text: 'Item 1' }] }, + }); + + this.instance.option('suggestions.items', [{ text: 'New 1' }, { text: 'New 2' }]); + + assert.strictEqual(this.getSuggestionItems().length, 2, 'items count updated via nested path'); + assert.strictEqual(this.getSuggestionItems().eq(0).text(), 'New 1', 'first item text updated'); + }); }); QUnit.module('Data Layer Integration', { From d82f25e7f80819378689b0788ef2961156caea17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marker=20dao=20=C2=AE?= Date: Thu, 16 Apr 2026 14:23:21 +0200 Subject: [PATCH 2/2] fix(optionChanged) --- .../devextreme/js/__internal/ui/chat/chat.ts | 4 ++-- .../chatParts/chat.tests.js | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/devextreme/js/__internal/ui/chat/chat.ts b/packages/devextreme/js/__internal/ui/chat/chat.ts index 8caf6ec4bfad..81549c6a5dae 100644 --- a/packages/devextreme/js/__internal/ui/chat/chat.ts +++ b/packages/devextreme/js/__internal/ui/chat/chat.ts @@ -787,8 +787,8 @@ class Chat extends Widget { this._messageBox.option(name, this._getSendButtonOptionsWithAction()); break; case 'suggestions': { - const options = Widget.getOptionsFromContainer(args); - this._suggestions?.updateOptions(options); + const { suggestions } = this.option(); + this._suggestions?.updateOptions(suggestions); break; } default: diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets/chatParts/chat.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets/chatParts/chat.tests.js index 541e26164c7e..806400237bd4 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets/chatParts/chat.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets/chatParts/chat.tests.js @@ -2832,6 +2832,25 @@ QUnit.module('Chat', () => { assert.strictEqual(this.getSuggestionItems().length, 2, 'items count updated via nested path'); assert.strictEqual(this.getSuggestionItems().eq(0).text(), 'New 1', 'first item text updated'); }); + + QUnit.test('nested option update should not drop other suggestions options', function(assert) { + assert.expect(1); + + const clickedText = 'Item 1'; + + this.reinit({ + suggestions: { + items: [{ text: clickedText }], + onItemClick: (e) => { + assert.strictEqual(e.itemData.text, clickedText, 'onItemClick preserved after nested update'); + }, + }, + }); + + this.instance.option('suggestions.items', [{ text: clickedText }, { text: 'Item 2' }]); + + this.getSuggestionItems().first().trigger('dxclick'); + }); }); QUnit.module('Data Layer Integration', {