Skip to content

Commit e5003e8

Browse files
committed
fix: get correct group steps to include
1 parent f505b8d commit e5003e8

File tree

1 file changed

+10
-8
lines changed
  • packages/frontend/src/components/Editor

1 file changed

+10
-8
lines changed

packages/frontend/src/components/Editor/index.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,21 @@ export default function Editor(props: EditorProps): React.ReactElement {
109109
// we include some grouped steps as there is no longer a nested editor
110110
// we identify the group by checking if the current step id is in the group
111111
//
112-
const groupStepsToInclude = useMemo(
113-
() =>
114-
groupedSteps.filter((group) =>
115-
group.some((step) => step.id === currentStepId),
116-
),
117-
[currentStepId, groupedSteps],
118-
)
112+
const groupStepsToInclude = useMemo(() => {
113+
const stepPosition = flow.steps.findIndex(
114+
(step) => step.id === currentStepId,
115+
)
116+
117+
return groupedSteps.flatMap((group) =>
118+
group.filter((step) => step.position <= stepPosition),
119+
)
120+
}, [currentStepId, flow.steps, groupedSteps])
119121

120122
const stepExecutionsToInclude = useMemo(
121123
() =>
122124
new Set([
123125
...stepsBeforeGroup.map((step) => step.id),
124-
...groupStepsToInclude.flatMap((step) => step.map((s) => s.id)),
126+
...groupStepsToInclude.map((s) => s.id),
125127
]),
126128
[stepsBeforeGroup, groupStepsToInclude],
127129
)

0 commit comments

Comments
 (0)