Selaa lähdekoodia

fix(typo): change select spelling mistake, visibileOption to visibleOption (#646)

Zn 3 vuotta sitten
vanhempi
sitoutus
faf15112c9
2 muutettua tiedostoa jossa 14 lisäystä ja 19 poistoa
  1. 12 17
      packages/semi-ui/select/index.tsx
  2. 2 2
      packages/semi-ui/select/virtualRow.tsx

+ 12 - 17
packages/semi-ui/select/index.tsx

@@ -754,31 +754,26 @@ class Select extends BaseComponent<SelectProps, SelectState> {
         this.foundation.handleOptionMouseEnter(optionIndex);
         this.foundation.handleOptionMouseEnter(optionIndex);
     }
     }
 
 
-    renderWithGroup(visibileOptions: OptionProps[]) {
+    renderWithGroup(visibleOptions: OptionProps[]) {
         const content: JSX.Element[] = [];
         const content: JSX.Element[] = [];
         const groupStatus = new Map();
         const groupStatus = new Map();
 
 
-        visibileOptions.forEach((option, optionIndex) => {
+        visibleOptions.forEach((option, optionIndex) => {
             const parentGroup = option._parentGroup;
             const parentGroup = option._parentGroup;
             const optionContent = this.renderOption(option, optionIndex);
             const optionContent = this.renderOption(option, optionIndex);
-            if (parentGroup && groupStatus.has(parentGroup.label)) {
-                // group content already insert
-                content.push(optionContent);
-            } else if (parentGroup) {
+            if (parentGroup && !groupStatus.has(parentGroup.label)) {
+                // when use with OptionGroup and group content not already insert
                 const groupContent = <OptionGroup {...parentGroup} key={parentGroup.label} />;
                 const groupContent = <OptionGroup {...parentGroup} key={parentGroup.label} />;
                 groupStatus.set(parentGroup.label, true);
                 groupStatus.set(parentGroup.label, true);
                 content.push(groupContent);
                 content.push(groupContent);
-                content.push(optionContent);
-            } else {
-                // when not use with OptionGroup
-                content.push(optionContent);
-            }
+            } 
+            content.push(optionContent);
         });
         });
 
 
         return content;
         return content;
     }
     }
 
 
-    renderVirtualizeList(visibileOptions: OptionProps[]) {
+    renderVirtualizeList(visibleOptions: OptionProps[]) {
         const { virtualize } = this.props;
         const { virtualize } = this.props;
         const { direction } = this.context;
         const { direction } = this.context;
         const { height, width, itemSize } = virtualize;
         const { height, width, itemSize } = virtualize;
@@ -787,9 +782,9 @@ class Select extends BaseComponent<SelectProps, SelectState> {
             <List
             <List
                 ref={this.virtualizeListRef}
                 ref={this.virtualizeListRef}
                 height={height || numbers.LIST_HEIGHT}
                 height={height || numbers.LIST_HEIGHT}
-                itemCount={visibileOptions.length}
+                itemCount={visibleOptions.length}
                 itemSize={itemSize}
                 itemSize={itemSize}
-                itemData={{ visibileOptions, renderOption: this.renderOption }}
+                itemData={{ visibleOptions, renderOption: this.renderOption }}
                 width={width || '100%'}
                 width={width || '100%'}
                 style={{ direction }}
                 style={{ direction }}
             >
             >
@@ -814,11 +809,11 @@ class Select extends BaseComponent<SelectProps, SelectState> {
         } = this.props;
         } = this.props;
 
 
         // Do a filter first, instead of directly judging in forEach, so that the focusIndex can correspond to
         // Do a filter first, instead of directly judging in forEach, so that the focusIndex can correspond to
-        const visibileOptions = options.filter(item => item._show);
+        const visibleOptions = options.filter(item => item._show);
 
 
-        let listContent: JSX.Element | JSX.Element[] = this.renderWithGroup(visibileOptions);
+        let listContent: JSX.Element | JSX.Element[] = this.renderWithGroup(visibleOptions);
         if (virtualize) {
         if (virtualize) {
-            listContent = this.renderVirtualizeList(visibileOptions);
+            listContent = this.renderVirtualizeList(visibleOptions);
         }
         }
 
 
         const style = { minWidth: dropdownMinWidth, ...dropdownStyle };
         const style = { minWidth: dropdownMinWidth, ...dropdownStyle };

+ 2 - 2
packages/semi-ui/select/virtualRow.tsx

@@ -5,8 +5,8 @@ export interface VirtualRowProps{
     style?: React.CSSProperties;
     style?: React.CSSProperties;
 }
 }
 const VirtualRow = ({ index, data, style }: VirtualRowProps) => {
 const VirtualRow = ({ index, data, style }: VirtualRowProps) => {
-    const { visibileOptions } = data;
-    const option = visibileOptions[index];
+    const { visibleOptions } = data;
+    const option = visibleOptions[index];
     return data.renderOption(option, index, style);
     return data.renderOption(option, index, style);
 };
 };