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


##########
superset-frontend/packages/superset-ui-core/src/components/Select/AsyncSelect.tsx:
##########
@@ -160,6 +160,13 @@ const AsyncSelect = forwardRef(
     const [allValuesLoaded, setAllValuesLoaded] = useState(false);
     const selectValueRef = useRef(selectValue);
     const fetchedQueries = useRef(new Map<string, number>());
+    const initialOptionsRef = useRef<SelectOptionsType>(EMPTY_OPTIONS);
+    const inputValueRef = useRef('');
+    // Counts fetches whose `.finally` has not yet run. Loading is cleared only
+    // when this drops to 0, so a stale response (which returns early without
+    // updating selectOptions) cannot flip the spinner off while a newer
+    // request is still pending.
+    const inFlightFetchesRef = useRef(0);

Review Comment:
   `initialOptionsRef` introduces an additional internal cache of base 
(no-search) options, but the public `AsyncSelectRef.clearCache()` currently 
only clears `fetchedQueries`. After calling `clearCache()`, clearing a search 
can still restore stale options from `initialOptionsRef.current` until the next 
base fetch completes. Consider updating `clearCache()` to also reset 
`initialOptionsRef.current` (and any other derived cached state, if 
appropriate) so the imperative API truly clears all cached options.



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