"min" and "max" attributes for inputs with type="date" are strings
purcell opened this issue · 5 comments
Hi! I noticed that "min" and "max" are constrained to the type Number in the allowed attributes list for input elements. In the case of "date" inputs, these attributes must contain strings (see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date). I'm not sure what the best solution would be here... maybe a different element type for dateInput? Happy to submit code if you can suggest a way forward.
Hmm, that's unfortunate. Usually this just means we change it to String to include both use cases, since there isn't a good way to tie the input's type attribute to the types of the other attributes.
Creating a separate dateInput could work for that particular case, but most people would probably not see it and continue using input { type: "date" }. And there are many other APIs like this making it complicated fast.
My recommendation would be to create a dateInput component in your own application with types much more specific to your use case (and if it's generic enough to be a good 3rd party component publish it 🙂 ).
My recommendation would be to create a
dateInputcomponent in your own application with types much more specific to your use case (and if it's generic enough to be a good 3rd party component publish it 🙂 ).
Yep, that probably makes sense - thanks! Might also be worth considering changing the attribute type eventually anyway.
Yes, definitely, I'll leave this open for that.
FWIW, my current simple workaround is the following:
type Props_dateInput = (max :: String , min :: String | R.Props_input)
dateInput :: forall attrs attrs_ . Union attrs attrs_ (R.SharedProps Props_dateInput)
=> Record attrs -> JSX
dateInput = element (R.unsafeCreateDOMComponent "input") <<< union { "type": "date" }This is addressed by #84, which I think is overdue for merging.