]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-19236 Fix hotspot assignee selection dropdown which resets the search after...
author7PH <benjamin.raymond@sonarsource.com>
Thu, 15 Jun 2023 08:59:41 +0000 (10:59 +0200)
committersonartech <sonartech@sonarsource.com>
Thu, 15 Jun 2023 20:03:02 +0000 (20:03 +0000)
server/sonar-web/design-system/src/components/SearchSelectDropdown.tsx

index 96480ed7d7e4597dab25cf2bb94e07e0df3be6cc..f44bff6484db16cfbe35d0d04ac50c5b272357a1 100644 (file)
@@ -78,6 +78,8 @@ export function SearchSelectDropdown<
     minLength,
     controlAriaLabel,
     menuIsOpen,
+    onChange,
+    onInputChange,
     zLevel = PopupZLevel.Global,
     ...rest
   } = props;
@@ -102,9 +104,9 @@ export function SearchSelectDropdown<
   const handleChange = React.useCallback(
     (newValue: OnChangeValue<Option, IsMulti>, actionMeta: ActionMeta<Option>) => {
       toggleDropdown(false);
-      props.onChange?.(newValue, actionMeta);
+      onChange?.(newValue, actionMeta);
     },
-    [toggleDropdown, props.onChange]
+    [toggleDropdown, onChange]
   );
 
   const handleLoadOptions = React.useCallback(
@@ -117,11 +119,16 @@ export function SearchSelectDropdown<
 
   const handleInputChange = React.useCallback(
     (newValue: string, actionMeta: InputActionMeta) => {
-      const value = actionMeta.action === 'menu-close' ? actionMeta.prevInputValue : newValue;
-      setInputValue(value);
-      props.onInputChange?.(value, actionMeta);
+      if (actionMeta.action === 'menu-close') {
+        setInputValue(actionMeta.prevInputValue);
+        return actionMeta.prevInputValue;
+      }
+
+      setInputValue(newValue);
+      onInputChange?.(newValue, actionMeta);
+      return newValue;
     },
-    [props.onInputChange]
+    [onInputChange]
   );
 
   React.useEffect(() => {