Skip to content

Commit 7912e91

Browse files
authored
Chat: it should be possible to update one item or item's field (T1290746) (#29834)
1 parent bfc91b8 commit 7912e91

File tree

2 files changed

+25
-1
lines changed
  • packages/devextreme

2 files changed

+25
-1
lines changed

packages/devextreme/js/__internal/ui/chat/chat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ class Chat extends Widget<Properties> {
324324
break;
325325
}
326326
case 'items':
327-
this._messageList.option(name, value);
327+
this._messageList.option(name, this.option('items'));
328328
this._updateMessageBoxAria();
329329
break;
330330
case 'dataSource':

packages/devextreme/testing/tests/DevExpress.ui.widgets/chatParts/chat.tests.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,30 @@ QUnit.module('Chat', () => {
200200
assert.deepEqual(messageList.option('items'), newItems, 'items value is updated');
201201
});
202202

203+
QUnit.test('items should be passed to messageList after update only one item (T1290746)', function(assert) {
204+
this.reinit({
205+
items: [{ text: 'one' }, { text: 'two' }],
206+
});
207+
208+
this.instance.option('items[0]', { text: 'new one' });
209+
210+
const messageList = this.getMessageList();
211+
212+
assert.deepEqual(messageList.option('items'), [{ text: 'new one' }, { text: 'two' }], 'items value is updated');
213+
});
214+
215+
QUnit.test('items should be passed to messageList after update only one item field (T1290746)', function(assert) {
216+
this.reinit({
217+
items: [{ text: 'one' }, { text: 'two' }],
218+
});
219+
220+
this.instance.option('items[0].text', 'new one');
221+
222+
const messageList = this.getMessageList();
223+
224+
assert.deepEqual(messageList.option('items'), [{ text: 'new one' }, { text: 'two' }], 'items value is updated');
225+
});
226+
203227
['showDayHeaders', 'showAvatar', 'showUserName', 'showMessageTimestamp'].forEach(option => {
204228
QUnit.test(`Chat should pass ${option} to messageList on init`, function(assert) {
205229
this.reinit({

0 commit comments

Comments
 (0)