Skip to content

Commit 4a3123b

Browse files
authored
List: empty message should be hidden when new item is inserted to empty store (T1277567)
1 parent c404ec8 commit 4a3123b

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import domAdapter from '@js/core/dom_adapter';
22
import $ from '@js/core/renderer';
33
import { findChanges } from '@js/core/utils/array_compare';
4-
import { noop } from '@js/core/utils/common';
54
import { when } from '@js/core/utils/deferred';
65
import { extend } from '@js/core/utils/extend';
76
import { each } from '@js/core/utils/iterator';
@@ -191,7 +190,9 @@ export default CollectionWidget.inherit({
191190
}
192191
},
193192

194-
_afterItemElementInserted: noop,
193+
_afterItemElementInserted(): void {
194+
this._renderEmptyMessage();
195+
},
195196

196197
_removeByChange(keyInfo, items, change, isPartialRefresh) {
197198
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)