-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
MudSlider: Add nullable value parameter #8881
Conversation
@henon @danielchalmers is this good enough? |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #8881 +/- ##
==========================================
+ Coverage 89.82% 90.22% +0.39%
==========================================
Files 412 424 +12
Lines 11878 12286 +408
Branches 2364 2406 +42
==========================================
+ Hits 10670 11085 +415
+ Misses 681 669 -12
- Partials 527 532 +5 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that resolves it just fine. In the example a Button to reset the nullable value to null would be awesome.
Added to v7.0.0 Migration Guide #8447 |
I will add explicit bUnit test if @danielchalmers approves this approach. |
The alert is not relevant anymore in the example. Added trick that it will work when you two way bind two values. I noticed that now when the knob is in the begging and since it stays at zero, if you touch the knob but not move it the value update will not trigger means the nullabeValue will also stay null. I don't think i can force |
If it becomes a problem we'll find a solution later. Hasn't been one in 3+ years so don't hold your breath ;) |
Thanks @ScarletKuro. I think it's strange that you have to use a different binding when Value works for the other inputs but I'm just looking forward to having the functionality. I updated to the new property ( - <MudSlider @bind-Value="Point.SleepHours" Variant="Variant.Filled" Min="0" Max="24" Step="0.5m" Size="Size.Large" Immediate />
+ <MudSlider @bind-NullableValue="Point.SleepHours" Variant="Variant.Filled" Min="0" Max="24" Step="0.5m" Size="Size.Large" Immediate /> But get build errors:
If I add
|
Try |
<MudSlider T="decimal" @bind-NullableValue="_point.SleepHours" Variant="Variant.Filled" Min="0" Max="24" Step="0.5m" Size="Size.Large" Immediate />
@code {
private readonly Point _point = new();
public class Point
{
public decimal? SleepHours { get; set; }
}
} This just works for me. I guess blazor is having hard time to guess the generics in this case. Since some values are int(min, max) some are decimals (step) and the bind value is nullable.
You are not suppose to set |
Well, we discussed multiples times before if having two value bindings is an adequate solution, and we agreed with @henon that it is. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+<MudSlider T="decimal" @bind-NullableValue="Point.SleepHours" Variant="Variant.Filled" Min="0" Max="24" Step="0.5m" Size="Size.Large" />
Worked 👍
Added tests. |
Thanks! |
Description
Fixes: #8860 (comment)
How Has This Been Tested?
Type of Changes
Checklist
dev
).