Skip to content

Commit

Permalink
fix: `TypeError: Cannot read properties of undefined (reading 'data')…
Browse files Browse the repository at this point in the history
…` in `autoAnswerableFlag` (#4033)
  • Loading branch information
jessicamcinchak authored Dec 3, 2024
1 parent 5f79efc commit bc7a818
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions editor.planx.uk/src/pages/FlowEditor/lib/store/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,8 @@ export const previewStore: StateCreator<
const node = flow[id];
if (!node) return;

const { type, data, edges } = node;
// Only Question & Checklist nodes that have an fn & edges are eligible for auto-answering
const { type, data, edges } = node;
if (
!type ||
!SUPPORTED_DECISION_TYPES.includes(type) ||
Expand Down Expand Up @@ -630,9 +630,12 @@ export const previewStore: StateCreator<
*/
autoAnswerableFlag: (filterId: NodeId) => {
const { breadcrumbs, flow } = get();
const { type, data, edges } = flow[filterId];

const node = flow[filterId];
if (!node) return;

// Only Filter nodes that have an fn & edges are eligible for auto-answering
const { type, data, edges } = node;
if (!type || type !== TYPES.Filter || !data?.fn || !edges) return;

// Get all options (aka flags or edges or Answer nodes) for this node
Expand Down

0 comments on commit bc7a818

Please sign in to comment.