Blazored / Modal

A powerful and customizable modal implementation for Blazor applications.
https://blazored.github.io/Modal/
MIT License
786 stars 186 forks source link

[Bug] When an app's current culture doesn't use a period as a decimal separator, fade-in/-out animation fails #235

Closed AgWillow closed 4 years ago

AgWillow commented 4 years ago

When a Blazor app's current culture doesn't use a period [.] as a decimal separator, the fade-in/-out animation fails.

To reproduce:

  1. Configure a Blazor app to set CultureInfo.CurrentCulture to any culture that doesn't use a period decimal separator, e.g., French (fr, fr-CA, etc.).
  2. Open a modal dialog via IModalService.Show<...>("...", options) with options.Animation = ModalAnimation.FadeInOut(.333333)

Upon fade-in, only the scrim appears. If ModalAnimation.FadeOut(.333333) is used instead, the modal appears, but its closing is not animated.

Expected behavior The modal dialog should fade in/out as it does when the culture's decimal separator is a period, e.g., US English.

Additional context The logic that creates the in-line style for the modal uses the default (culture-sensitive) formatting to render the animation duration.

larsk2009 commented 4 years ago

I can reproduce this issue, and I think the PR you made is a good way to solve this issue. I am just curious when you would actually encounter this issue, because as far as I can see it would only happen when you have more than 3 decimal places behind the delimiter. I can only think of situations when maybe you are dividing some numbers giving this many places behind the comma. Is that what you were doing?

AgWillow commented 4 years ago

... maybe you are dividing some numbers giving this many places behind the comma. Is that what you were doing?

Yes, exactly. I wrote the duration as 1./3. and that's when I saw it fail (after switching my app to French).

larsk2009 commented 4 years ago

Yeah that makes sense.