Skip to content

Commit 5850e96

Browse files
authored
Chat: it should be possible to update one item or item's field (T1290746)
1 parent b6add0c commit 5850e96

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
@@ -564,7 +564,7 @@ class Chat extends Widget<Properties> {
564564
case 'editing':
565565
break;
566566
case 'items':
567-
this._messageList.option(name, value);
567+
this._messageList.option(name, this.option('items'));
568568
this._updateMessageBoxAria();
569569
break;
570570
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
@@ -273,6 +273,30 @@ QUnit.module('Chat', () => {
273273
assert.deepEqual(messageList.option('items'), newItems, 'items value is updated');
274274
});
275275

276+
QUnit.test('items should be passed to messageList after update only one item (T1290746)', function(assert) {
277+
this.reinit({
278+
items: [{ text: 'one' }, { text: 'two' }],
279+
});
280+
281+
this.instance.option('items[0]', { text: 'new one' });
282+
283+
const messageList = this.getMessageList();
284+
285+
assert.deepEqual(messageList.option('items'), [{ text: 'new one' }, { text: 'two' }], 'items value is updated');
286+
});
287+
288+
QUnit.test('items should be passed to messageList after update only one item field (T1290746)', function(assert) {
289+
this.reinit({
290+
items: [{ text: 'one' }, { text: 'two' }],
291+
});
292+
293+
this.instance.option('items[0].text', 'new one');
294+
295+
const messageList = this.getMessageList();
296+
297+
assert.deepEqual(messageList.option('items'), [{ text: 'new one' }, { text: 'two' }], 'items value is updated');
298+
});
299+
276300
['showDayHeaders', 'showAvatar', 'showUserName', 'showMessageTimestamp'].forEach(option => {
277301
QUnit.test(`Chat should pass ${option} to messageList on init`, function(assert) {
278302
this.reinit({

0 commit comments

Comments
 (0)