Skip to content

Commit f6a29d6

Browse files
Lookup: Fix load indicator when minSearchLength specified (T1215813) (#28834)
1 parent 520a1f1 commit f6a29d6

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

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

32733312

0 commit comments

Comments
 (0)