epam / UUI

React-based components and accelerators library built by EPAM Systems.
https://uui.epam.com/
MIT License
162 stars 61 forks source link

[NumericInput]: Why is placeholder replaced when there is a value? #2225

Closed RomainGoncalves closed 1 month ago

RomainGoncalves commented 2 months ago

Now

The placeholder attribute gets updated by the value passed to the component when there is a value of type number. Why is that? Here: https://github.com/epam/UUI/blob/main/uui-components/src/inputs/NumericInput.tsx#L97

To Do

I would assume that the placeholder should not change as it is a prop that we can pass to the component. A prop shouldn't be changed by a component's implementation

Describe the solution you'd like (optional)

The placeholder value is the one defined when calling the component.

AlekseyManetov commented 1 month ago

That's a hack we're using to display the value as a string in order to apply formatting (e.g., thousand separator), since the input type 'number' doesn't support any symbols other than numbers. Unfortunately, this is the only way to achieve this behavior.

Anyway , placeholder prop is passed to the UUI component, not to the native input. Therefore, you shouldn't assume that this prop should be present in the DOM as you passed, we can use it in any other way. We simply guarantee that the value of this prop will be displayed when the NumericInput doesn't have any value.