Skip to content

Fix Trigger UI form rendering for null enum values#62060

Open
Subham-KRLX wants to merge 1 commit intoapache:mainfrom
Subham-KRLX:fix/trigger-form-enum-null-rendering
Open

Fix Trigger UI form rendering for null enum values#62060
Subham-KRLX wants to merge 1 commit intoapache:mainfrom
Subham-KRLX:fix/trigger-form-enum-null-rendering

Conversation

@Subham-KRLX
Copy link
Contributor

@Subham-KRLX Subham-KRLX commented Feb 17, 2026

This PR fixes a regression where the Trigger UI form crashes if a parameter's enum contains null (used to make fields optional).

The zag-js library (used by Chakra UI's Select component) requires string values for dropdown items. When null is passed in an enum, it causes a crash with [zag-js] No value found for item {"label":null,"value":null}.

This fix:

  1. In FieldDropdown.tsx, null enum values are converted to the string "null" specifically for the UI rendering.
  2. When the value changes, the string "null" is converted back to the actual null primitive in the form state.
  3. labelLookup is updated to safely handle null keys.

I've added comprehensive unit tests in FieldDropdown.test.tsx covering:

  • Rendering mixed enums with null
  • Custom labels for null via values_display
  • Clearing selections
  • Form submission correctness

closes: #62049


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

@boring-cyborg boring-cyborg bot added the area:UI Related to UI/UX. For Frontend Developers. label Feb 17, 2026
@Subham-KRLX Subham-KRLX force-pushed the fix/trigger-form-enum-null-rendering branch from 8157c2b to 88a1b18 Compare February 17, 2026 04:37
Copy link
Contributor

@jscheffl jscheffl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static checks are failing most probably you should install prekand run static checks locally. What I see as compliaints can all be auo-fixed.

7: "Seven",
8: "Eight",
9: "Nine",
None: "None (clear selection)",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the values display for null is not working, it always displays nullas literal:

Image

const labelLookup = (key: string, valuesDisplay: Record<string, string> | undefined): string => {
const labelLookup = (key: number | string | null, valuesDisplay: Record<string, string> | undefined): string => {
// Convert null to string to avoid issues with object key lookup
const stringKey = key === null ? "null" : String(key);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the replacement is a good idea such that the used library does not fail. But in my view the literal null looks a bit dangerous as I assume it might be really used as a value / string.

Would it be possible to rather switch to some exotic string with less potential for clash like __null__ or __#null#__? Woul dbe good to define this as constant that it is used consistently in code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the implementation to use a constant null internally to avoid potential clashes with literal string values. I have also fixed the values_display lookup logic to correctly handle None keys (by adding a fallback check for 'None'). Additionally I ran a full suite of static checks (prek/eslint) to fix all formatting and linting issues.

@Subham-KRLX Subham-KRLX force-pushed the fix/trigger-form-enum-null-rendering branch from 88a1b18 to 39b82c7 Compare February 18, 2026 02:16
@Subham-KRLX Subham-KRLX force-pushed the fix/trigger-form-enum-null-rendering branch from 39b82c7 to b8d6de2 Compare February 18, 2026 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:UI Related to UI/UX. For Frontend Developers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trigger UI form fails rendering if value with enum contains "null" value

2 participants