Browse Source

fix: Fix the problem that AutoComplete cannot select the value after long press and trigger onSelect (#1682)

YyumeiZhang 2 years ago
parent
commit
9599591f0c
1 changed files with 7 additions and 4 deletions
  1. 7 4
      packages/semi-foundation/autoComplete/foundation.ts

+ 7 - 4
packages/semi-foundation/autoComplete/foundation.ts

@@ -155,7 +155,7 @@ class AutoCompleteFoundation<P = Record<string, any>, S = Record<string, any>> e
         this._adapter.notifySearch(inputValue);
         this._adapter.notifyChange(inputValue);
         this._modifyFocusIndex(inputValue);
-        if (!this.isPanelOpen){
+        if (!this.isPanelOpen) {
             this.openDropdown();
         }
     }
@@ -335,6 +335,9 @@ class AutoCompleteFoundation<P = Record<string, any>, S = Record<string, any>> e
             case KeyCode.ESC:
                 this.closeDropdown();
                 break;
+            case KeyCode.TAB:
+                this.closeDropdown();
+                break;
             default:
                 break;
         }
@@ -383,7 +386,7 @@ class AutoCompleteFoundation<P = Record<string, any>, S = Record<string, any>> e
 
     _handleArrowKeyDown(offset: number): void {
         const { visible } = this.getStates();
-        if (!visible){
+        if (!visible) {
             this.openDropdown();
         } else {
             this._getEnableFocusIndex(offset);  
@@ -392,7 +395,7 @@ class AutoCompleteFoundation<P = Record<string, any>, S = Record<string, any>> e
 
     _handleEnterKeyDown() {
         const { visible, options, focusIndex } = this.getStates();
-        if (!visible){
+        if (!visible) {
             this.openDropdown();
         } else {
             if (focusIndex !== undefined && focusIndex !== -1 && options.length !== 0) {
@@ -424,7 +427,7 @@ class AutoCompleteFoundation<P = Record<string, any>, S = Record<string, any>> e
         // internal-issues:1231
         setTimeout(() => {
             this._adapter.notifyBlur(e);
-            this.closeDropdown();
+            // this.closeDropdown();
         }, 100);
     }
 }