Select to view content in your preferred language

Setting value of calcite-input-number does not work if value is a number

83
4
Jump to solution
a week ago
ChristopheSuter
Regular Contributor

Setting the value of a calcite-input-number does work only if value is a string

See:

https://codepen.io/christophesuter/pen/YPzQXRz?editors=1011

if changing the code input.value=23 to input.value='23' it works

Is this the expected behavior for the future versions ? If not, does anyone have a workaround for this ?

 

0 Kudos
1 Solution

Accepted Solutions
DitwanDPrice
Esri Contributor

Hey Christophe, 

Yes this is expected and is the intended behavior going forward. The is in line with the native input element where the `value` is always a string. 

View solution in original post

4 Replies
CodyPatterson
MVP Regular Contributor

Hey @ChristopheSuter 

I've noticed this as well when working in Calcite, but I haven't found a guaranteed fix other than converting the value to a string when it's assigned. I used String(variable) and it dynamically converts it for me. I experimented a bit with your CodePen, but it seems it must be normal.

Cody

ChristopheSuter
Regular Contributor

Hi @CodyPatterson, basically I have migrated the Core API, so I jumped from 2.10.1 to 3.0.3 and this was not the case before... just wanted to know if converting all to string was mandatory now ..

CodyPatterson
MVP Regular Contributor

Hey @ChristopheSuter 

I see what you mean, I started in version 2.13 and had this issue as well, after upgrading last week to 3.0.3, it still continues, I'd assume this will be the case for the time being until it is changed, I found the GitHub page for it, and see if I can raise an issue if I figure out what could be causing it!

Cody

0 Kudos
DitwanDPrice
Esri Contributor

Hey Christophe, 

Yes this is expected and is the intended behavior going forward. The is in line with the native input element where the `value` is always a string.