snehilvj / dash-mantine-components

Plotly Dash components based on Mantine React Components
https://www.dash-mantine-components.com
MIT License
570 stars 56 forks source link

`NumberInput` with value being str doesn't increment nor decrement properly #413

Open NOTMEE12 opened 2 days ago

NOTMEE12 commented 2 days ago

If I have a dmc.NumberInput with value="1234" then if I press up or down arrows then it doesn't work properly. It will change the value to 0.

Example code:

from dash import Dash
from dash._dash_renderer import _set_react_version
_set_react_version("18.2.0")
import dash_mantine_components as dmc

app = Dash(__name__)

app.layout = dmc.MantineProvider(dmc.Stack([
    dmc.Title("Normal number input", order=4),
    dmc.NumberInput(value=1234),
    dmc.Title("Number input with value as str", order=4),
    dmc.NumberInput(value="1234"),
    dmc.Title("Number input with value as str and value is numeric string on", order=4),
    dmc.NumberInput(value="1234", valueIsNumericString=True),
    dmc.Title("Number input with leading zeros on", order=4),
    dmc.NumberInput(value=1234, allowLeadingZeros=True),
    dmc.Title("Number input with leading zeros on and value is str", order=4),
    dmc.NumberInput(value="001234", allowLeadingZeros=True),
    dmc.Title("Number input with value as str and value is numeric string and leading zeros on", order=4),
    dmc.NumberInput(value="1234", valueIsNumericString=True, allowLeadingZeros=True),
], gap="xs", m="sm"))

if __name__ == '__main__':
    app.run()
AnnMarieW commented 1 day ago

Hi @NOTMEE12

Thanks for the good example. I confirmed over in the Mantine discord that this component expects a number rather than a string when the number is valid.

Looks like there may be a patch to fix this based on discord discussion