-
Notifications
You must be signed in to change notification settings - Fork 459
[Slider] Binding issues #2612
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
[Slider] Binding issues #2612
Conversation
Unit Tests
Details on your Workflow / Core Tests page. |
|
@oneolddev Hi Gary, were you able to make any progress on this? |
@vnbaaij, Hi Vincent Sorry, I got busy with another more pressing issue. I believe I have a fix for this problem. I'm not quite sure how to add my changes to your PR so I added some comments as part of the code review. Below is a summary. Changes to OnAfterRenderAsync in FluentSlider.razor.cs protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
_jsModule ??= await JSRuntime.InvokeAsync<IJSObjectReference>("import", JAVASCRIPT_FILE);
}
else
{
if (_jsModule is not null)
{
await _jsModule!.InvokeVoidAsync("updateSlider", Element);
}
}
}Remove from FluentSlider.razor aria-valuenow="@FormatValueAsString(Value)"The root cause of the slider issue is the expected two-way binding behaviour. What actually is happening is that thumbnail is only rendered on the first render of the slider web component. Subsequent changes in the value do not result in the thumbnail being redrawn which is the expected behaviour. The call to |
|
I spoke too soon. I'm now seeing the jittering in the the datagrid. 😢 |
|
The jittering occurs when dragging the thumbnail. As the thumbnail is dragged, the value is being updated causing a rerender. |
|
I have a fix for this issue. It required me to specifically target those states where the slider thumbnail needed to be redrawn. |
|
Resolved with #2665 |
Storing the situation as described in last issue comment: #2609 (comment)
Explanation:
Given the question "How can I reset the slider value?" we've found there is an issue with doing that. We are using the following sample code (slightly adapted version from the code used in the issue):
What I've found so far:
FluentSlider.razorWorks when using the Blazor code from above. What does not work is using the Slider inside another component that can influence the slider's value. I'm using the DataGrid Typical Usage filter example for this. moving the thumb a couple of times in quick succession throws it into a loop:

Not adding the
current-valueto the slider tag and using the script for earlier PR that Gary (@oneolddev) mentioned has the same result (reset works, grid goes into loop) if we invoke the js function on every render (ie inOnAfterRenderAsyncbut outside of `firstRender' block):If we move the script call to inside the
firstRenderblock, the data grid filter example works flawlessly. @LuohuaRain's code works for some part not not completely. If you move a slider and then press reset, the value gets set to 0 but the thumb is not updated. If you press reset without moving a slider, it will set the value and the thumb correctly:Now we just need a working combination of these two. I've tried everything I could think of but was not able to find a definitive solution. So Gary, if your offer still stands, please take a look.