Преглед на файлове

fix: fix the problem that letters and numbers cannot be entered when using input class components in Dropdown (#1018)

YannLynn преди 3 години
родител
ревизия
2a1255497d
променени са 1 файла, в които са добавени 4 реда и са изтрити 2 реда
  1. 4 2
      packages/semi-foundation/dropdown/menuFoundation.ts

+ 4 - 2
packages/semi-foundation/dropdown/menuFoundation.ts

@@ -42,7 +42,8 @@ export default class DropdownMenuFoundation extends BaseFoundation<Partial<Defau
 
         if (this.firstChars.length === 0){
             this.menuItemNodes.forEach((item: Element) => {
-                this.firstChars.push(item.textContent.trim()[0].toLowerCase());
+                // the menuItemNodes can be an component and not exit textContent
+                this.firstChars.push(item.textContent.trim()[0]?.toLowerCase());
             });
         }
 
@@ -69,7 +70,8 @@ export default class DropdownMenuFoundation extends BaseFoundation<Partial<Defau
             default:
                 if (isPrintableCharacter(event.key)) {
                     this.setFocusByFirstCharacter(curItem, event.key);
-                    handlePrevent(event);
+                    // it can be an input on Dropdown, handlePrevent may affect the input of the component
+                    // handlePrevent(event); 
                 }
                 break;
         }