Fix Trigger UI form rendering for null enum values#62060
Fix Trigger UI form rendering for null enum values#62060Subham-KRLX wants to merge 1 commit intoapache:mainfrom
Conversation
8157c2b to
88a1b18
Compare
jscheffl
left a comment
There was a problem hiding this comment.
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)", |
| 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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
88a1b18 to
39b82c7
Compare
39b82c7 to
b8d6de2
Compare

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-jslibrary (used by Chakra UI's Select component) requires string values for dropdown items. Whennullis passed in an enum, it causes a crash with[zag-js] No value found for item {"label":null,"value":null}.This fix:
nullenum values are converted to the string"null"specifically for the UI rendering."null"is converted back to the actualnullprimitive in the form state.nullkeys.I've added comprehensive unit tests in FieldDropdown.test.tsx covering:
nullnullviavalues_displaycloses: #62049
Was generative AI tooling used to co-author this PR?