Closed eddie3ruff closed 1 month ago
It is a little similar to #3217 .
I change LOOPBACK = False
in .venv\Lib\site-packages\nicegui\elements\number.py
to LOOPBACK = True
.
The format shows corretly as set.
Following code shows that _props['model-value']
has changed,
but the value displayed in ui.number
is the same as the value when input is activated.
from nicegui import ui
un = ui.number(label='Test Field', min=1.0, max=100.0, step=1.0, value=10.0, format='%.2f')
ui.button('print',on_click=lambda :ui.notify(un._props))
ui.run()
I just created PR #3389 to update the number element on blur. This should apply the formatting as soon as the element looses focus.
This issue actually describes missing formatting when using the stepper buttons. But as far as I can tell, there is no easy way to discriminate stepper buttons from normal typing with the keyboard. And because we don't want to interfere the user typing on the keyboard, we don't want to send updates after using the steppers. But I guess that's ok, as long as the format is applied on blur.
Description
The displayed number starts correctly at 10.00 but after changing the value, the displayed number is only an integer with no decimal point. The '%.2f' format is ignored only for the displayed number unless the page is refreshed.
For example, we start at 10.00 which is correct, then we click increment and we get 11 which is wrong. It should be 11.00 If we refresh the page, we do in fact get 11.00