Skip to content

fix: form-render html widget crash when value not found in options - #1743

Open
jevonsflash wants to merge 1 commit into
alibaba:masterfrom
jevonsflash:fix/html-widget-undefined-option
Open

jevonsflash wants to merge 1 commit into
alibaba:masterfrom
jevonsflash:fix/html-widget-undefined-option

Conversation

@jevonsflash

Copy link
Copy Markdown

Problem

In form-render's html display widget, when the schema value is an array and one of its items no longer exists in options (e.g. options were changed after the form data was saved), options.find() returns undefined and item.label throws TypeError: Cannot read properties of undefined (reading 'label'), crashing the whole form render.

Fix

Use optional chaining in the array branch, consistent with the single-value branch right above it which already uses item?.label:

-        const name = item.label;
+        const name = item?.label;

When an item is not found in options, it is simply skipped in the display string instead of crashing the render.

Impact

Only packages/form-render/src/widgets/fields/html/index.tsx

options.find() may return undefined, accessing item.label directly throws TypeError. Use optional chaining like the single-value branch already does.
@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown

@jevonsflash is attempting to deploy a commit to the Faberon Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants