rusackas commented on code in PR #44880:
URL: https://github.com/apache/superset/pull/44880#discussion_r4162837761


##########
superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx:
##########
@@ -564,32 +608,27 @@ export default function PluginFilterSelect(props: 
PluginFilterSelectProps) {
     updateDataMaskRef.current = updateDataMask;
   }, [updateDataMask]);
 
-  const debouncedLikeChange = useMemo(
-    () =>
-      debounce((text: string) => {
-        if (text) {
-          updateDataMaskRef.current([text]);
-        } else {
-          updateDataMaskRef.current(null);
-        }
-      }, Constants.SLOW_DEBOUNCE),
-    [],
-  );
-
   useEffect(() => {
-    if (!isLikeOperator || clearAllTrigger) {
-      debouncedLikeChange.cancel();
+    if (
+      deferredPendingLikeValue === null ||
+      !isLikeOperator ||
+      clearAllTrigger
+    ) {
+      return;
     }
-  }, [clearAllTrigger, debouncedLikeChange, isLikeOperator]);
-
-  useEffect(() => () => debouncedLikeChange.cancel(), [debouncedLikeChange]);
+    if (deferredPendingLikeValue) {
+      updateDataMaskRef.current([deferredPendingLikeValue]);
+    } else {
+      updateDataMaskRef.current(null);
+    }
+  }, [deferredPendingLikeValue, isLikeOperator, clearAllTrigger]);

Review Comment:
   @sadpandajoe good catch. Leaving LIKE mode now clears `pendingLikeValue`, 
and the dispatch effect ignores any deferred value that lags the live one, so 
returning to Contains no longer replays the old text. Added a regression test.



##########
superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx:
##########
@@ -564,32 +608,27 @@ export default function PluginFilterSelect(props: 
PluginFilterSelectProps) {
     updateDataMaskRef.current = updateDataMask;
   }, [updateDataMask]);
 
-  const debouncedLikeChange = useMemo(
-    () =>
-      debounce((text: string) => {
-        if (text) {
-          updateDataMaskRef.current([text]);
-        } else {
-          updateDataMaskRef.current(null);
-        }
-      }, Constants.SLOW_DEBOUNCE),
-    [],
-  );
-
   useEffect(() => {
-    if (!isLikeOperator || clearAllTrigger) {
-      debouncedLikeChange.cancel();
+    if (
+      deferredPendingLikeValue === null ||

Review Comment:
   @sadpandajoe agreed. The dispatch effect now skips a deferred value that 
does not match the live `pendingLikeValue`, so a stale value cannot restore the 
predicate once the Clear All trigger is released. Added a regression test that 
types, clears, then releases the trigger.



-- 
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