fix: run card collapse flicker — auto-expand only on first load, not on every re-render
The load callback had expandedRunId in its dependency array, so collapsing (setting expandedRunId=null) triggered a reload which re-expanded it. Replaced with a useRef flag that fires once.
This commit is contained in:
parent
906b6491fe
commit
ff351b38d7
1 changed files with 5 additions and 3 deletions
|
|
@ -709,6 +709,7 @@ function RunList({ videoId, videoStatus }: { videoId: string; videoStatus: strin
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [expandedRunId, setExpandedRunId] = useState<string | null>(null);
|
const [expandedRunId, setExpandedRunId] = useState<string | null>(null);
|
||||||
const [showLegacy, setShowLegacy] = useState(false);
|
const [showLegacy, setShowLegacy] = useState(false);
|
||||||
|
const hasAutoExpanded = useRef(false);
|
||||||
|
|
||||||
const load = useCallback(async (silent = false) => {
|
const load = useCallback(async (silent = false) => {
|
||||||
if (!silent) setLoading(true);
|
if (!silent) setLoading(true);
|
||||||
|
|
@ -716,17 +717,18 @@ function RunList({ videoId, videoStatus }: { videoId: string; videoStatus: strin
|
||||||
const res = await fetchPipelineRuns(videoId);
|
const res = await fetchPipelineRuns(videoId);
|
||||||
setRuns(res.items);
|
setRuns(res.items);
|
||||||
setLegacyCount(res.legacy_event_count);
|
setLegacyCount(res.legacy_event_count);
|
||||||
// Auto-expand the latest run on first load
|
// Auto-expand the latest run only on first load
|
||||||
if (!silent && res.items.length > 0 && expandedRunId === null) {
|
if (!hasAutoExpanded.current && res.items.length > 0) {
|
||||||
const firstRun = res.items[0];
|
const firstRun = res.items[0];
|
||||||
if (firstRun) setExpandedRunId(firstRun.id);
|
if (firstRun) setExpandedRunId(firstRun.id);
|
||||||
|
hasAutoExpanded.current = true;
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
// silently fail
|
// silently fail
|
||||||
} finally {
|
} finally {
|
||||||
if (!silent) setLoading(false);
|
if (!silent) setLoading(false);
|
||||||
}
|
}
|
||||||
}, [videoId, expandedRunId]);
|
}, [videoId]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
void load();
|
void load();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue