Skip to content

Commit c454736

Browse files
Lookup: Fix load indicator when minSearchLength specified (T1215813) (#28831)
1 parent e84df95 commit c454736

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,20 @@ const Lookup = DropDownList.inherit({
811811
}
812812
},
813813

814+
_filterDataSource(...args) {
815+
if (this._list && !this._list._dataSource && this._isMinSearchLengthExceeded()) {
816+
this._list?._scrollView.startLoading();
817+
}
818+
819+
this.callBase(...args);
820+
},
821+
822+
_dataSourceFiltered(...args) {
823+
this.callBase(...args);
824+
825+
this._list?._scrollView.finishLoading();
826+
},
827+
814828
_updateActiveDescendant() {
815829
this.callBase();
816830

packages/devextreme/testing/tests/DevExpress.ui.widgets.editors/lookup.tests.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3399,6 +3399,45 @@ QUnit.module('dataSource integration', {
33993399

34003400
assert.ok($loadPanel.is(':visible'), 'load panel is visible');
34013401
});
3402+
3403+
QUnit.test('load panel should be displayed if search value length exceed minSearchLength and showDataBeforeSearch=false, (T1215813)', function(assert) {
3404+
const loadDelay = 1000;
3405+
const timeoutDelay = 100;
3406+
const instance = this.$element.dxLookup({
3407+
dataSource: {
3408+
load: () => {
3409+
const d = new $.Deferred();
3410+
3411+
setTimeout(() => {
3412+
d.resolve([]);
3413+
}, loadDelay);
3414+
3415+
return d;
3416+
}
3417+
},
3418+
searchEnabled: true,
3419+
showDataBeforeSearch: false,
3420+
minSearchLength: 3,
3421+
searchTimeout: timeoutDelay,
3422+
useNativeScrolling: false,
3423+
opened: true
3424+
}).dxLookup('instance');
3425+
3426+
const $content = $(instance.content());
3427+
const $input = $content.find(`.${LOOKUP_SEARCH_CLASS} .${TEXTEDITOR_INPUT_CLASS}`);
3428+
const $loadPanel = $content.find(`.${SCROLL_VIEW_LOAD_PANEL_CLASS}`);
3429+
const keyboard = keyboardMock($input);
3430+
3431+
keyboard.type('abc');
3432+
this.clock.tick(timeoutDelay + loadDelay / 2);
3433+
assert.ok($loadPanel.is(':visible'), 'load panel is visible');
3434+
this.clock.tick(loadDelay / 2);
3435+
assert.ok($loadPanel.is(':hidden'), 'load panel is not visible when loading has been finished');
3436+
3437+
keyboard.press('backspace');
3438+
this.clock.tick(loadDelay / 2);
3439+
assert.ok($loadPanel.is(':hidden'), 'load panel is not visible if value length less than minSearchLength)');
3440+
});
34023441
});
34033442

34043443

0 commit comments

Comments
 (0)