You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "Copilot (via GitHub)" <gi...@apache.org> on 2025/11/13 18:34:49 UTC

Re: [PR] fix: dashboard filter regress [superset]

Copilot commented on code in PR #35218:
URL: https://github.com/apache/superset/pull/35218#discussion_r2524517212


##########
superset-frontend/packages/superset-ui-core/src/components/Select/Select.tsx:
##########
@@ -400,7 +400,11 @@ const Select = forwardRef(
       onSearch?.(searchValue);
     }, Constants.FAST_DEBOUNCE);
 
-    useEffect(() => () => handleOnSearch.cancel(), [handleOnSearch]);
+    useEffect(() => {
+      if (handleOnSearch !== undefined) {
+        handleOnSearch.cancel();
+      }

Review Comment:
   The useEffect is missing a cleanup function return. Currently, `handleOnSearch.cancel()` is called immediately when the effect runs (i.e., whenever `handleOnSearch` changes), instead of being called during cleanup when the component unmounts.
   
   This should be:
   ```tsx
   useEffect(() => {
     return () => {
       if (handleOnSearch !== undefined) {
         handleOnSearch.cancel();
       }
     };
   }, [handleOnSearch]);
   ```
   
   Or more concisely:
   ```tsx
   useEffect(() => () => handleOnSearch?.cancel(), [handleOnSearch]);
   ```
   ```suggestion
         return () => {
           if (handleOnSearch !== undefined) {
             handleOnSearch.cancel();
           }
         };
   ```



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org