frzyc / genshin-optimizer

An Artifact optimizer for Genshin Impact.
https://frzyc.github.io/genshin-optimizer/
MIT License
777 stars 228 forks source link

TextFieldLazy handling for numeric inputs #2124

Closed frzyc closed 4 months ago

frzyc commented 4 months ago

Using MUI textfield is somewhat annoying, since using type='number' allows a bunch of non strictly numbers, like e,-, which has traditionally been hard to parse.

MUI team advices against using this as well: https://mui.com/material-ui/react-text-field/#type-quot-number-quot

Handling for numeric inputs should follow more like this example: https://codesandbox.io/p/sandbox/https-github-com-mui-material-ui-issues-36415-orxx4r?file=%2Fsrc%2FApp.tsx

For TextFieldLazy, need to pass in a regex prop that facilities this behaviour, or create a separate component for handling number inputs, like NumberInputLazy(might be easier to migrate to Number Input once MUI team releases it).