Skip to content

Commit 6eaf3c0

Browse files
Lookup: Fix load indicator when minSearchLength specified (T1215813) (#28833)
1 parent dac127a commit 6eaf3c0

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
@@ -783,6 +783,20 @@ const Lookup = DropDownList.inherit({
783783
}
784784
},
785785

786+
_filterDataSource(...args) {
787+
if (this._list && !this._list._dataSource && this._isMinSearchLengthExceeded()) {
788+
this._list?._scrollView.startLoading();
789+
}
790+
791+
this.callBase(...args);
792+
},
793+
794+
_dataSourceFiltered(...args) {
795+
this.callBase(...args);
796+
797+
this._list?._scrollView.finishLoading();
798+
},
799+
786800
_updateActiveDescendant() {
787801
this.callBase();
788802

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
@@ -3267,6 +3267,45 @@ QUnit.module('dataSource integration', {
32673267

32683268
assert.ok($loadPanel.is(':visible'), 'load panel is visible');
32693269
});
3270+
3271+
QUnit.test('load panel should be displayed if search value length exceed minSearchLength and showDataBeforeSearch=false, (T1215813)', function(assert) {
3272+
const loadDelay = 1000;
3273+
const timeoutDelay = 100;
3274+
const instance = this.$element.dxLookup({
3275+
dataSource: {
3276+
load: () => {
3277+
const d = new $.Deferred();
3278+
3279+
setTimeout(() => {
3280+
d.resolve([]);
3281+
}, loadDelay);
3282+
3283+
return d;
3284+
}
3285+
},
3286+
searchEnabled: true,
3287+
showDataBeforeSearch: false,
3288+
minSearchLength: 3,
3289+
searchTimeout: timeoutDelay,
3290+
useNativeScrolling: false,
3291+
opened: true
3292+
}).dxLookup('instance');
3293+
3294+
const $content = $(instance.content());
3295+
const $input = $content.find(`.${LOOKUP_SEARCH_CLASS} .${TEXTEDITOR_INPUT_CLASS}`);
3296+
const $loadPanel = $content.find(`.${SCROLL_VIEW_LOAD_PANEL_CLASS}`);
3297+
const keyboard = keyboardMock($input);
3298+
3299+
keyboard.type('abc');
3300+
this.clock.tick(timeoutDelay + loadDelay / 2);
3301+
assert.ok($loadPanel.is(':visible'), 'load panel is visible');
3302+
this.clock.tick(loadDelay / 2);
3303+
assert.ok($loadPanel.is(':hidden'), 'load panel is not visible when loading has been finished');
3304+
3305+
keyboard.press('backspace');
3306+
this.clock.tick(loadDelay / 2);
3307+
assert.ok($loadPanel.is(':hidden'), 'load panel is not visible if value length less than minSearchLength)');
3308+
});
32703309
});
32713310

32723311

0 commit comments

Comments
 (0)