TecKnow / STADiceRoller

Dice roller and probability visualizer compatible with the Star Trek Adventures TTRPG.
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Should leading zeroes in input fields be cleared? #4

Closed TecKnow closed 1 year ago

TecKnow commented 1 year ago

Fixing issue #2 resulted in a situation where numeric input boxes preserve leading zeroes. For example, the value "03" is treated as the number 3 but the leading zero is preserved. Should they be trimmed?

I suspect this is because somewhere internally React is using type conversion, so the input field value like "02" compares as equal to the number 2, and the state does not get updated, because from the perspective of React it has not changed.

Setting the value equal to a string does work to fix the issue because the string "02" doesn't equal the string "2."

TecKnow commented 1 year ago

I have decided that the contents of these fields should probably be normalized, meaning that leading zeroes should be stripped.

Implementing this should probably wait until the project switches to Material UI however.