NumberInput.value
vs int
#102
Replies: 1 comment 15 replies
-
@maratori I did some research on the browser side
NumberInput.value I think it would be most consistent to copy the behavior of the browser at let To have NumberInput.valid I am not completely sure about this property. We could let the browser send the return code of |
Beta Was this translation helpful? Give feedback.
-
In Lona 1.7
NumberInput
was added to work with<input type="number">
. It was undocumented because we may want to change it in the next release.Now all properties (
value
,step
,min
,max
) haveOptional[float]
type.Most users will work with whole numbers only. And they will have to convert
int(node.value)
each time. It seems reasonable to provide some builtin option to haveint
directly.I did two failed attempts in #87. The first was to add separate
IntNumberInput
, the second is to determine type based onstep
. Both seem bad options. Why? In two words value inside browser can befloat
even if it is invalid (see details).Let's add new read-only property
NumberInput.int_value
.NumberInput(step=0.1).int_value
)int
if currentvalue
is valid integerNone
if currentvalue
is invalid (for exampleNumberInput(value=3, min=5).int_value is None
andNumberInput(value=0.5, min=0, step=1).int_value is None
)If you see better options, you are welcome.
Beta Was this translation helpful? Give feedback.
All reactions