Przeglądaj źródła

fix: [select] need click twice when using renderCreateItem, close #574 (#576)

pointhalo 3 lat temu
rodzic
commit
2748f4e209
1 zmienionych plików z 6 dodań i 1 usunięć
  1. 6 1
      packages/semi-ui/select/index.tsx

+ 6 - 1
packages/semi-ui/select/index.tsx

@@ -739,7 +739,12 @@ class Select extends BaseComponent<SelectProps, SelectState> {
 
         return (
             // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/interactive-supports-focus
-            <div role="button" aria-label="Use the input box to create an optional item" onClick={e => this.onSelect(option, optionIndex, e)} key={new Date().valueOf()}>
+            <div
+                role="button"
+                aria-label="Use the input box to create an optional item"
+                onClick={e => this.onSelect(option, optionIndex, e)}
+                key={option.key || option.label}
+            >
                 {customCreateItem}
             </div>
         );