spacemonkd commented on code in PR #9928:
URL: https://github.com/apache/ozone/pull/9928#discussion_r2954801397


##########
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/components/select/multiSelect.tsx:
##########
@@ -97,44 +155,190 @@ const MultiSelect: React.FC<MultiSelectProps> = ({
         )}
         {isDisabled
           ? placeholder
-          : `${placeholder}: ${selected.filter((opt) => opt.value !== 
fixedColumn).length} selected`
+          : `${placeholder}: ${selected.filter((opt) => 
!fixedKeys.includes(opt.value)).length} selected`
         }
       </components.ValueContainer>
     );
   };
 
-  const finalStyles = {...selectStyles, ...style ?? {}}
+  // Stable custom Input — suppresses react-select's blur-driven menu close
+  // while the user interacts with the search box inside the menu.
+  const InputComponent = useMemo(
+    () => (({ onBlur, ...inputProps }: any) => {
+      const handleBlur = (e: React.FocusEvent<HTMLElement>) => {
+        if (searchInteracting.current) return;
+        if (onBlur) onBlur(e);
+      };
+      return <input {...inputProps} onBlur={handleBlur} />;
+    }) as React.FC,
+    [] // searchInteracting captured by ref — always current
+  );
 
-  const fixedOption = fixedColumn ? options.find((opt) => opt.value === 
fixedColumn) : undefined;
-  const selectableOptions = fixedColumn ? options.filter((opt) => opt.value 
!== fixedColumn) : options;
+  // Stable MenuList — created once, reads current values from stateRef at
+  // call time to avoid stale closures without re-creating the component type.
+  const MenuListComponent = useMemo(
+    () => ({ children, ...menuListProps }: any) => {
+      const {
+        searchTerm,
+        setSearchTerm,
+        showSearch,
+        showSelectAll,
+        selected,
+        selectableOptions,
+        fixedOptions,
+        options,
+        onChange
+      } = stateRef.current;

Review Comment:
   Might be better to move this out to it's own component under select/ to 
avoid memoization.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to