Skip to content

Commit

Permalink
fix(navigation): dont hide subflows by index
Browse files Browse the repository at this point in the history
Co-Authored-By: Alex August Schlote <[email protected]>
  • Loading branch information
chohner and aaschlote committed Mar 21, 2024
1 parent 62871b2 commit 81265c2
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions app/components/FlowNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,30 +67,11 @@ export default function FlowNavigation({
}

function isSubflowVisible(navItems: NavItem[], index: number) {
if (index === 0) return true;
const { state } = navItems[index];
const isCurrentState = state === NavState.Current;
const isDoneState = state === NavState.Done;
const isReachableState = [
NavState.Open,
NavState.Current,
NavState.Done,
].includes(state);

let isPreviousSubflowReachable = false;

for (let previousIndex = index - 1; previousIndex >= 0; previousIndex--) {
const previousSubflow = navItems[previousIndex];
if (previousSubflow.state !== NavState.OpenDisabled) {
isPreviousSubflowReachable = previousSubflow.state === NavState.Done;
break;
}
}

return (
isCurrentState ||
isDoneState ||
(isReachableState && isPreviousSubflowReachable)
index === 0 ||
[NavState.Open, NavState.Current, NavState.Done].includes(
navItems[index].state,
)
);
}

Expand Down

0 comments on commit 81265c2

Please sign in to comment.