react-forms icon indicating copy to clipboard operation
react-forms copied to clipboard

Number input never renders the placeholder

Open havelock opened this issue 8 years ago • 1 comments

It seems impossible to see the placeholder for the <Number /> input element.

Whenever initialValue/defaultValue props are passed 0, null, undefined or even "" values the value="0" HTML attribute is always rendered.

The only solution for displaying the placeholder is passing value="" prop, but obviously the prop doesn't use the built-in onChange handling then and becomes non-editable.

<Number
  name="somename"
  placeholder={"Test placeholder"}
/>

havelock avatar Feb 08 '18 16:02 havelock

Hey @havelock. <Number /> is a tricky component. At the moment it does not accept placeholder prop. The problem is with how Modifiers work. I'd recommend you to use <Text /> instead and parse it into number you need (e.g. parseInt).

MartynasZilinskas avatar Feb 12 '18 23:02 MartynasZilinskas