Open bluepuma77 opened 1 year ago
This is weird, because setting value to null
works correctly. I would need reproducible example.
The error from your log is probably referring to this line:
(stringValue || '').split(',')
but as you can see, null
value is handled properly by replacing with empty string
@bluepuma77 Are you sure you are binding string as a value?
@mskocik Sorry, it's a big setup, so reproduction would take some time.
Today I got a slightly different error:
TypeError: value.split is not a function
at Module.initProps (/Users/Develop/node_modules/svelty-picker/dist/utils/state.js:22:66)
at /Users/Develop/node_modules/svelty-picker/dist/components/SveltyPicker.svelte:94:47
at Object.$$render (/Users/Develop/node_modules/svelte/src/runtime/internal/ssr.js:156:16)
at /Users/Develop/src/routes/incident/InputDate.svelte:13:54
which points to this line:
22 let valueArray = value ? (Array.isArray(value) ? value : value.split(',')) : [];
I think I might bind a Date instead of a String.
And when I turn it into a String, then SuperForms using its schema indicates the field as error...
yes, passing the Date would explain given error. String is expected, Date objects are used internally. But they are exported on dateChange
event, if that would help your use case.
@mskocik Would the current architecture allow for an extension like
<SveltyPicker
name={name}
bind:date={form[name]}
/>
to enable a date variable to be passed in and out?
I would need to try it out, but I think it might be possible but I wouldn't recommend it due possible issues across timezones
@bluepuma77 Is this still relevant for you?
For now I switched to date-picker-svelte because that uses Date and therefore works better with SuperForms.
Trying to get svelty-picker to work with sveltekit-superforms and my own form input builder.
My current issue is that after submit and reload, svelty-picker breaks, I assume because the
bind:value
isnull
orundefined
.Is it possible to improve this, so even if
null
orundefined
is supplied, the date is shown empty and not breaking the component? Maybe some more checking or usingtry catch
?