Skip to content

Commit 7ce1263

Browse files
authored
List: empty message should be hidden when new item is inserted to empty store (T1277567)
1 parent 79021d2 commit 7ce1263

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

packages/devextreme/js/__internal/ui/collection/m_collection_widget.live_update.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@ class CollectionWidgetLiveUpdate<
210210
}
211211
}
212212

213-
_afterItemElementInserted(): void {}
213+
_afterItemElementInserted(): void {
214+
this._renderEmptyMessage();
215+
}
214216

215217
_removeByChange(keyInfo, items, change, isPartialRefresh): void {
216218
const index = isPartialRefresh ? change.index : indexByKey(keyInfo, items, change.key);

packages/devextreme/testing/tests/DevExpress.ui.widgets/listParts/liveUpdateTests.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'ui/list';
66

77
const LIST_ITEM_CLASS = 'dx-list-item';
88
const LIST_GROUP_CLASS = 'dx-list-group';
9+
const EMPTY_MESSAGE_CLASS = 'dx-empty-message';
910

1011
QUnit.module('live update', {
1112
beforeEach: function() {
@@ -208,6 +209,26 @@ QUnit.module('live update', {
208209
assert.deepEqual(this.itemDeletedSpy.firstCall.args[0].itemData.id, pushData[0].key, 'check removed item key');
209210
});
210211

212+
QUnit.test('Empty message should be hidden after new element is pushed to empty store (T1277567)', function(assert) {
213+
const clock = sinon.useFakeTimers();
214+
const list = this.createList({
215+
dataSource: new DataSource({
216+
key: 'id',
217+
store: []
218+
})
219+
});
220+
const store = list.getDataSource().store();
221+
222+
assert.strictEqual(list.$element().find(`.${EMPTY_MESSAGE_CLASS}`).length, 1, 'empty message is shown');
223+
224+
store.push([{ type: 'insert', data: { id: 2 }, index: 0 }]);
225+
clock.tick(0);
226+
227+
assert.strictEqual(list.$element().find(`.${EMPTY_MESSAGE_CLASS}`).length, 0, 'empty message is hidden');
228+
229+
clock.restore();
230+
});
231+
211232
QUnit.test('remove two items', function(assert) {
212233
const store = this.createList({
213234
dataSource: {

0 commit comments

Comments
 (0)