Repository navigation
[Bug]: Form field with value={null} submits null, so an empty Cc/Bcc crashes extensions that call .split #1898
Unanswered
JackGallowitz
asked this question in
Issue Triage
Replies: 1 comment
|
Thanks for opening this! Tinycast stays small and focused, so new features are chosen Tip Planning to build this? Discussing the approach here first is highly preferred. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
What happened?
Submitting the Apple Mail extension's Share with Mail form throws when Cc and Bcc are left empty:
The extension does
values.cc.split(",");values.ccisnull.Steps to reproduce
yug2005, https://www.raycast.com/yug2005/mail).useFormgetsinitialValues.cc === undefined.Expected
The form submits
cc: ""andbcc: "", and the compose window opens. That is what the same extension gets in Raycast.Actual
It submits
cc: null, andvalues.cc.split(",")throws.Root cause
@raycast/utilsuseFormmaps a field whose value isundefinedtovalue: nullinitemProps(bundled code:value: typeof m > "u" ? null : m), which the extension spreads into the field as<Form.TextField value={null}>.The runtime treats
nullas a controlled value and keeps it,Scripts/raycast-runtime/src/api/components.js:97-112:collectValues(same file, line 276) then handsnulltoonSubmit. Onlyundefinedcounts as "no value" today;nulldoes not.Reproduced
On
mainat 58168bf, with the runtime harness against the prebuiltTinycast/Resources/RaycastRuntime.generated.js, a form with<Form.TextField id="cc" value={null}>and a plain<Form.TextField id="bcc">:Suggested fix
Treat
nulllikeundefinedinuseFieldValue, somakeField's fallback applies:""for text fields,[]for Tag/FilePicker,falsefor Checkbox.Form.DatePickerfalls back tonull, so it needs the value kept asnullrather than"". A fixture withvalue={null}on aForm.TextFieldthat submits""covers it.Related
useFieldValue/form state codeForm.TextFieldstoreValuedoes not persist submitted values — same areaEnvironment
All reactions