Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/devextreme/js/__internal/ui/chat/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -786,9 +786,11 @@ class Chat extends Widget<ChatProperties> {
this._createSendButtonAction();
this._messageBox.option(name, this._getSendButtonOptionsWithAction());
break;
case 'suggestions':
this._suggestions?.updateOptions(value as ChatProperties['suggestions']);
case 'suggestions': {
const { suggestions } = this.option();
this._suggestions?.updateOptions(suggestions);
break;
}
default:
super._optionChanged(args);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2821,6 +2821,36 @@ 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');
Comment thread
marker-dao marked this conversation as resolved.
});

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', {
Expand Down
Loading