Skip to content

Commit

Permalink
fix: Fix an issue with returning array in function for options and ch…
Browse files Browse the repository at this point in the history
…eckboxes
  • Loading branch information
tjtanjin committed Sep 14, 2024
1 parent c79e065 commit 7c2ef1b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/services/BlockService/CheckboxProcessor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ export const processCheckboxes = async (flow: Flow, block: Block, path: keyof Fl
if (parsedCheckboxes instanceof Promise) {
parsedCheckboxes = await parsedCheckboxes;
}
} else if (Array.isArray(checkboxes)) {
parsedCheckboxes = {items: checkboxes};
} else {
parsedCheckboxes = checkboxes;
}

// if array provided, transform to object with default values
if (Array.isArray(parsedCheckboxes)) {
parsedCheckboxes = {items: parsedCheckboxes};
}

// nothing to render if no items present
if (!("items" in parsedCheckboxes)) {
return;
Expand Down
7 changes: 5 additions & 2 deletions src/services/BlockService/OptionProcessor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ export const processOptions = async (flow: Flow, block: Block, path: keyof Flow,
if (parsedOptions instanceof Promise) {
parsedOptions = await parsedOptions;
}
} else if (Array.isArray(options)) {
parsedOptions = {items: options};
} else {
parsedOptions = options;
}

// if array provided, transform to object with default values
if (Array.isArray(parsedOptions)) {
parsedOptions = {items: parsedOptions};
}

// nothing to render if no items present
if (!("items" in parsedOptions)) {
return;
Expand Down

0 comments on commit 7c2ef1b

Please sign in to comment.