Closed alfonsogarciacaro closed 5 years ago
Hmm, I guess in both cases there is a possibility that the user can make mistakes.
With Multiple false
you still allow the use of an array.
Perhaps you need a select_multiple
function and remove the Multiple property all together.
Would not break the select function that much but introduce some duplication.
@alfonsogarciacaro Hum...
I do like the fact that we are force to use string
for Value
. For example, if you works with number and make Value of obj
then users would be tempted to pass an int
or float
value directly and I am not sure it will have the correct behavior.
Perhaps, we can provide something like [<CompiledName("value")>] MultipleValue of string []
?
Also using U2<string, string[]>
will make the code more cryptic and harder to write.
input [ Value !^"my-value"]
IMHO we should avoid this at all cost :)
Hmm, select_multiple
could work but although we're adding helpers for other things like React.memo
I'd prefer to keep the HTML native elements untouched so things like html-to-elmish work. I like the solution of adding a different prop, maybe ValueMultiple
so it works better with autocompletion, let's do that!
Actually, I just noticed I had turned Value of string
to Value of obj
and month ago and I had forgotten 😅 Anyways, I've changed it back to string and added ValueMultiple of string[]
. Not sure how it can work with SSR exactly so for now I just disabled it.
When using a
select
element that hasMultiple true
property, React forces us to pass a string array asValue
, however this prop is currently typed asValue of string
, which makes unboxing a needed (after the dev discover the error at runtime).We have two solutions to fix this:
obj
as we have done for other items, I assume the runtime will automatically transform things as numbers to string, but it may not be the format they expect.U2<string, string[]>
, which will break a lot of code forcing devs to add!^
everywhere.What do you think? @MangelMaxime @nojaf