Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NumericEdit not working with @bind-Value #360

Closed
Andy74 opened this issue Nov 19, 2019 · 4 comments
Closed

NumericEdit not working with @bind-Value #360

Andy74 opened this issue Nov 19, 2019 · 4 comments
Labels
Type: Bug 🐞 Something isn't working
Projects
Milestone

Comments

@Andy74
Copy link

Andy74 commented Nov 19, 2019

It seems impossible to edit a NumericEdit with decimal numbers. When trying to type 1.2 the value will be changed to 12.
This behavior occurs, when binding the value with "bind-Value". When binding with "Value" then one can edit the number with ".".

Also at the start, the value will be shown with comma instead of point as separator.
So it seems, that here the formatting of the number will be done by the culture of the browser/system and not by the setting "DecimalsSeparator" (in my case I have german as my system culture).

here is my example code:

<NumericEdit TValue="double" @bind-Value="@dummyNumber1" DecimalsSeparator="."/>
@code 
{
    double dummyNumber1 { get; set; }
protected override async Task OnInitializedAsync()
    {
        dummyNumber1 = 42.5;
    }
}
@stsrki
Copy link
Collaborator

stsrki commented Nov 19, 2019

I just tried it and you're right it doesn't work. I will need to investigate more to see what's the actual problem. Thanks for reporting.

@stsrki stsrki added this to the 0.8.8 milestone Nov 29, 2019
@stsrki stsrki added the Type: Bug 🐞 Something isn't working label Nov 29, 2019
@stsrki stsrki added this to Backlog in Development via automation Nov 30, 2019
@stsrki stsrki moved this from Backlog to To do in Development Nov 30, 2019
@stsrki stsrki moved this from To do to In progress in Development Nov 30, 2019
@stsrki
Copy link
Collaborator

stsrki commented Dec 1, 2019

I managed to make it work. The problem is actually bigger than expected and it's not so much in Blazorise as it's in the browsers support. Specifically in the localization of input fields. https://www.ctrl.blog/entry/html5-input-number-localization.html

To make it work I had to add support for lang attribute. So when defining the NumericEdit it also have to be defined. If left undefined it will fallback to CultureInfo.InvariantCulture. It acts more as a hint for Blazorise so it can know how to format the entered value.

Example:

<NumericEdit TValue="double" lang="en-us" @bind-Value="@dummyNumber1" DecimalsSeparator="." />
@code
{
    double dummyNumber1 { get; set; }
    protected override Task OnInitializedAsync()
    {
        dummyNumber1 = 42.5;

        return base.OnInitializedAsync();
    }
}

@stsrki stsrki closed this as completed Dec 2, 2019
Development automation moved this from In progress to Done Dec 2, 2019
@Andy74
Copy link
Author

Andy74 commented Dec 4, 2019

today I updated Visual Studio, so that I now have netcore 3.1, which is necessary for blazories 0.8.7.1.
then I tried your example, but I still have the same issues with NumericEdit. (I use Chrome 78.0.3904.108). Has anybody any hints, what can be wrong?

@stsrki
Copy link
Collaborator

stsrki commented Dec 4, 2019

The issue is fixed in 0.8.8 which is still in development. It's not yet ready to be available.

Also I will update Blazorise to 3.1 today.

@stsrki stsrki mentioned this issue Jan 2, 2020
23 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug 🐞 Something isn't working
Projects
Development
  
✔ Done
Development

No branches or pull requests

2 participants