Fix parameter toggle not collapsing auto-expanded rows (#SKY-7982) (#4741)
Co-authored-by: Suchintan Singh <suchintan@skyvern.com>
This commit is contained in:
@@ -293,11 +293,13 @@ function Workflows() {
|
||||
expandedRows,
|
||||
toggleExpanded: toggleParametersExpanded,
|
||||
setAutoExpandedRows,
|
||||
setManuallyExpandedRows,
|
||||
} = useParameterExpansion();
|
||||
|
||||
useEffect(() => {
|
||||
if (!isSearchActive) {
|
||||
setAutoExpandedRows([]);
|
||||
setManuallyExpandedRows(new Set());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -316,7 +318,13 @@ function Workflows() {
|
||||
setAutoExpandedRows(
|
||||
matchingWorkflows.map((workflow) => workflow.workflow_permanent_id),
|
||||
);
|
||||
}, [isSearchActive, workflows, matchesParameter, setAutoExpandedRows]);
|
||||
}, [
|
||||
isSearchActive,
|
||||
workflows,
|
||||
matchesParameter,
|
||||
setAutoExpandedRows,
|
||||
setManuallyExpandedRows,
|
||||
]);
|
||||
|
||||
function handleRowClick(
|
||||
event: React.MouseEvent<HTMLTableCellElement>,
|
||||
|
||||
@@ -25,10 +25,19 @@ function useParameterExpansion() {
|
||||
}, []);
|
||||
|
||||
const expandedRows = useMemo(() => {
|
||||
const combined = new Set(autoExpandedRows);
|
||||
for (const id of manuallyExpandedRows) {
|
||||
const combined = new Set<string>();
|
||||
// Symmetric difference (XOR): a row is expanded if it's in one set but not both.
|
||||
// This lets manual toggles override auto-expansion (and vice versa).
|
||||
for (const id of autoExpandedRows) {
|
||||
if (!manuallyExpandedRows.has(id)) {
|
||||
combined.add(id);
|
||||
}
|
||||
}
|
||||
for (const id of manuallyExpandedRows) {
|
||||
if (!autoExpandedRows.has(id)) {
|
||||
combined.add(id);
|
||||
}
|
||||
}
|
||||
return combined;
|
||||
}, [autoExpandedRows, manuallyExpandedRows]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user