Skip to content

Commit 0dd9f8f

Browse files
author
marker dao ®
committed
research
1 parent 585669d commit 0dd9f8f

3 files changed

Lines changed: 49 additions & 27 deletions

File tree

packages/devextreme/js/__internal/ui/drop_down_editor/m_drop_down_list.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ const SEARCH_MODES = ['startswith', 'contains', 'endwith', 'notcontains'];
4848
const useCompositionEvents = devices.real().platform !== 'android';
4949

5050
interface DropDownListProperties extends Omit<dxDropDownListOptions<DropDownList>,
51-
'onOpened' | 'onClosed'
52-
| 'onChange' | 'onCopy' | 'onCut' | 'onEnterKey' | 'onFocusIn' | 'onFocusOut' | 'onInput' | 'onKeyDown' | 'onKeyUp' | 'onPaste'
53-
| 'onValueChanged' | 'validationMessagePosition' | 'onContentReady' | 'onDisposing' | 'onOptionChanged' | 'onInitialized'> {
51+
'onOpened' | 'onClosed'
52+
| 'onChange' | 'onCopy' | 'onCut' | 'onEnterKey' | 'onFocusIn' | 'onFocusOut' | 'onInput' | 'onKeyDown' | 'onKeyUp' | 'onPaste'
53+
| 'onValueChanged' | 'validationMessagePosition' | 'onContentReady' | 'onDisposing' | 'onOptionChanged' | 'onInitialized'> {
5454
encodeNoDataText?: boolean;
5555
}
5656

@@ -624,7 +624,7 @@ class DropDownList<
624624
dataSource: this._getDataSource(),
625625
_dataController: this._dataController,
626626
hoverStateEnabled: this._isDesktopDevice() ? hoverStateEnabled : false,
627-
focusStateEnabled: this._isDesktopDevice() ? focusStateEnabled : false,
627+
focusStateEnabled,
628628
_onItemsRendered: (): void => {
629629
// @ts-expect-error ts-error
630630
this._popup.repaint();
@@ -699,7 +699,7 @@ class DropDownList<
699699
}
700700

701701
// eslint-disable-next-line @typescript-eslint/no-unused-vars
702-
_listItemClickHandler(e?): void {}
702+
_listItemClickHandler(e?): void { }
703703

704704
_setListDataSource(): void {
705705
if (!this._list) {
@@ -733,10 +733,10 @@ class DropDownList<
733733
_canKeepDataSource(): boolean {
734734
const isMinSearchLengthExceeded = this._isMinSearchLengthExceeded();
735735
return this._dataController.isLoaded()
736-
&& this.option('showDataBeforeSearch')
737-
&& this.option('minSearchLength')
738-
&& !isMinSearchLengthExceeded
739-
&& !this._isLastMinSearchLengthExceeded;
736+
&& this.option('showDataBeforeSearch')
737+
&& this.option('minSearchLength')
738+
&& !isMinSearchLengthExceeded
739+
&& !this._isLastMinSearchLengthExceeded;
740740
}
741741

742742
_searchValue() {
@@ -992,10 +992,13 @@ class DropDownList<
992992
this._dataExpressionOptionChanged(args);
993993
switch (args.name) {
994994
case 'hoverStateEnabled':
995-
case 'focusStateEnabled':
996995
this._isDesktopDevice() && this._setListOption(args.name, args.value);
997996
super._optionChanged(args);
998997
break;
998+
case 'focusStateEnabled':
999+
this._setListOption(args.name, args.value);
1000+
super._optionChanged(args);
1001+
break;
9991002
case 'items':
10001003
if (!this.option('dataSource')) {
10011004
this._processDataSourceChanging();

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

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ class Lookup extends DropDownList<LookupProperties> {
294294
});
295295
}
296296

297-
_fireContentReadyAction() {}
297+
_fireContentReadyAction() { }
298298

299299
_popupWrapperClass() {
300300
return '';
@@ -371,7 +371,7 @@ class Lookup extends DropDownList<LookupProperties> {
371371
}
372372
}
373373

374-
_renderButtonContainers(): void {}
374+
_renderButtonContainers(): void { }
375375

376376
_renderFieldTemplate(template) {
377377
this._$field.empty();
@@ -671,7 +671,7 @@ class Lookup extends DropDownList<LookupProperties> {
671671
}
672672
}
673673

674-
_preventFocusOnPopup(): void {}
674+
_preventFocusOnPopup(): void { }
675675

676676
_shouldLoopFocusInsidePopup(): boolean {
677677
const {
@@ -765,32 +765,43 @@ class Lookup extends DropDownList<LookupProperties> {
765765
}
766766

767767
_popupToolbarItemsConfig() {
768+
const { focusStateEnabled, applyButtonText: text } = this.option();
769+
768770
return [
769771
{
770772
shortcut: 'done',
771773
options: {
774+
text,
775+
focusStateEnabled,
772776
onClick: this._applyButtonHandler.bind(this),
773-
text: this.option('applyButtonText'),
774777
},
775778
},
776779
];
777780
}
778781

779782
_getCancelButtonConfig() {
780-
return this.option('showCancelButton') ? {
783+
const { focusStateEnabled, cancelButtonText: text, showCancelButton } = this.option();
784+
785+
return showCancelButton ? {
781786
shortcut: 'cancel',
782-
onClick: this._cancelButtonHandler.bind(this),
783787
options: {
784-
text: this.option('cancelButtonText'),
788+
text,
789+
focusStateEnabled,
785790
},
791+
onClick: this._cancelButtonHandler.bind(this),
786792
} : null;
787793
}
788794

789795
_getClearButtonConfig() {
790-
return this.option('showClearButton') ? {
796+
const { showClearButton, clearButtonText: text, focusStateEnabled } = this.option();
797+
798+
return showClearButton ? {
791799
shortcut: 'clear',
800+
options: {
801+
text,
802+
focusStateEnabled,
803+
},
792804
onClick: this._resetValue.bind(this),
793-
options: { text: this.option('clearButtonText') },
794805
} : null;
795806
}
796807

@@ -832,7 +843,7 @@ class Lookup extends DropDownList<LookupProperties> {
832843
this._renderSearch();
833844
}
834845

835-
_renderValueChangeEvent(): void {}
846+
_renderValueChangeEvent(): void { }
836847

837848
_renderSearch(): void {
838849
const isSearchEnabled = this.option('searchEnabled');
@@ -861,8 +872,10 @@ class Lookup extends DropDownList<LookupProperties> {
861872
onDisposing: () => isKeyboardListeningEnabled = false,
862873
// eslint-disable-next-line no-return-assign
863874
onFocusIn: () => isKeyboardListeningEnabled = true,
864-
// eslint-disable-next-line no-return-assign
865-
onFocusOut: () => isKeyboardListeningEnabled = false,
875+
onFocusOut: () => {
876+
isKeyboardListeningEnabled = false;
877+
this._list?.option('focusedElement', null);
878+
},
866879
// @ts-expect-error ts-error
867880
onKeyboardHandled: (opts) => isKeyboardListeningEnabled && this._list._keyboardHandler(opts),
868881
onValueChanged: (e) => this._searchHandler(e),
@@ -954,11 +967,11 @@ class Lookup extends DropDownList<LookupProperties> {
954967
this._searchBox?.option('placeholder', placeholder);
955968
}
956969

957-
_setAriaTargetForList(): void {}
970+
_setAriaTargetForList(): void { }
958971

959972
_listConfig() {
960973
return extend(super._listConfig(), {
961-
tabIndex: 0,
974+
tabIndex: this.option('searchEnabled') ? -1 : 0,
962975
grouped: this.option('grouped'),
963976
groupTemplate: this._getTemplateByOption('groupTemplate'),
964977
pullRefreshEnabled: this.option('pullRefreshEnabled'),
@@ -1093,6 +1106,7 @@ class Lookup extends DropDownList<LookupProperties> {
10931106
this._removeSearch();
10941107
this._renderSearch();
10951108
}
1109+
this._setListOption('tabindex', value ? -1 : 0);
10961110
break;
10971111
case 'searchPlaceholder':
10981112
this._setSearchPlaceholder();

packages/devextreme/playground/jquery.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<!DOCTYPE html>
22
<html lang="en">
3+
34
<head>
45
<title>DevExtreme jQuery Example</title>
56

@@ -52,9 +53,13 @@ <h1 style="position: fixed; left: 0; top: 0; clip: rect(1px, 1px, 1px, 1px);">Te
5253
<div id="button"></div>
5354
<script>
5455
$(() => {
55-
$("#button").dxButton({
56-
text: 'Click me!',
57-
onClick: () => { alert("clicked"); }
56+
$("#button").dxLookup({
57+
dataSource: ['A', 'B', 'C'],
58+
showClearButton: true,
59+
focusStateEnabled: true,
60+
searchEnabled: false,
61+
applyButtonText: 'OK',
62+
cancelButtonText: 'Delete',
5863
});
5964
});
6065
</script>

0 commit comments

Comments
 (0)