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


##########
superset-frontend/src/explore/components/controls/TextControl/index.tsx:
##########
@@ -95,26 +107,69 @@ function TextControl<T extends InputValueType = 
InputValueType>({
     [isFloat, isInt, onChange],
   );
 
-  const debouncedOnChangeRef = useRef(
-    debounce((inputValue: string, changeFn: (val: string) => void) => {
-      changeFn(inputValue);
+  // Read through a ref so a parent re-render that hands down a new `onChange`
+  // identity doesn't re-fire this effect on its own -- only an actual
+  // keystroke (a change to `deferredPendingValue`) should.
+  const handleChangeRef = useRef(handleChange);
+  handleChangeRef.current = handleChange;
+
+  // Outbound onChange keeps a trailing coalescing window so consumers
+  // (renderTrigger re-renders, filtered collection tables) only see the
+  // settled value rather than every intermediate keystroke the deferred value
+  // happens to commit.
+  // Newest raw keystroke, not yet emitted. Blur emits this rather than the
+  // (possibly lagging) deferred value so the last character is never lost.
+  const latestTypedRef = useRef<string | null>(null);
+  const debouncedEmitRef = useRef(
+    debounce((inputValue: string) => {
+      // A newer keystroke (or an external reset) has superseded this value;
+      // emitting it would echo back through the prop-sync branch and wipe the
+      // newer text.
+      if (latestTypedRef.current !== inputValue) {
+        return;
+      }

Review Comment:
   Good catch. The superseded emit now re-queues the newest typed value instead 
of returning, and the superseded test expects 12.



##########
superset-frontend/src/explore/components/ExploreViewContainer/index.tsx:
##########
@@ -428,6 +428,24 @@ function ExploreViewContainer(props: 
ExploreViewContainerProps) {
   /** set while the chart state of a popped history entry is being applied */
   const restoringFromHistory = useRef(false);
   const restoreTarget = useSelector(selectRestoreTarget, shallowEqual);
+  /**
+   * Axis title text no longer only settles on a debounce timer (TextControl
+   * now uses useDeferredValue), so a transient intermediate value -- e.g. a
+   * title cleared and immediately replaced -- can reach here mid-edit. These
+   * debounce the resulting margin adjustment so a fleeting empty/non-empty
+   * value doesn't clobber a margin the user already customized.
+   */

Review Comment:
   Applied the suggested comment wording.



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