fix(getElementInput): Select type number for HTMLSelectElement#259
fix(getElementInput): Select type number for HTMLSelectElement#259markojerkic wants to merge 2 commits intofabian-hiller:mainfrom
Conversation
|
Thank you! The bigger question here is if we should support number for |
|
Sure, that could be an option. But in the current state, it is very easy to assume that One solution is perhaps to create a Another solution would be to create safeguards. For example, if |
|
Thanks for the detailed answer! I still try to maintain Modular Forms, but I hardly add new features and extend the documentation because I have almost no time besides my studies and Valibot. But I still plan to rewrite Modular Forms one day. If this issue is a blocker for you, I will consider merging it. Otherwise I will consider your feedback when rewriting the library. |
|
It is not a blocker. Thank you for having a look at this PR. Transforming is a valid solution, although it wouldn't hurt to be a bit more explicit about what you can and cannot do. Feel free to close this PR if you don't feel it brings value. |
|
Thank you! I think it brings value. I will leave it open for now. I am just careful with my time as other projects like Valibot are a bit more important at the moment. |
d40777c to
750b759
Compare
Problem
When field type is number and
Fieldcomponent is bound to anHTMLSelectElement, form will always receiveundefined, asHTMLSelectElementdoes not have a propertyvalueAsNumber.Proposed solution
Add a check if element is
HTMLSelectElementand inputtypeis number. If true, then returnparseFloat(value).What I did
I started by implementing the Solid solution, updated the examples for Solid and then pretty much just copy-pasted the fix for React, Preact and Qwik. I tested them all, they seem to work just fine.