-
Notifications
You must be signed in to change notification settings - Fork 380
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
fix: Cross Dependent sliders do not reset thumb after range is updated. #1836
Comments
Hi, Unfortunately, the needed sync is not hooked up in the underlying web component. There exists a please raise an issue in the microsoft/fast repo for this |
I have a temporary work-around if you are interested. I derived a new component called MyFluentSlider.razor@inherits FluentSlider<TValue>
@typeparam TValue
@attribute [CascadingTypeParameter(nameof(TValue))]
<div @ref=container>
@{
base.BuildRenderTree(__builder);
}
</div> MyFluentSlider.razor.csusing Microsoft.AspNetCore.Components;
using Microsoft.FluentUI.AspNetCore.Components;
using Microsoft.JSInterop;
namespace Server.Components;
public partial class MyFluentSlider<TValue> : FluentSlider<TValue>, IAsyncDisposable
where TValue : System.Numerics.INumber<TValue>
{
private const string JAVASCRIPT_FILE = "./MyFluentSlider.js";
private ElementReference? container;
/// <summary />
[Inject]
private IJSRuntime JSRuntime { get; set; } = default!;
/// <summary />
private IJSObjectReference? Module { get; set; }
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
Module ??= await JSRuntime.InvokeAsync<IJSObjectReference>("import", JAVASCRIPT_FILE);
}
await Module!.InvokeVoidAsync("sliderUpdate", container);
}
public ValueTask DisposeAsync()
{
if (Module is not null)
{
return Module.DisposeAsync();
}
return ValueTask.CompletedTask;
}
} MyFluentSlider.jsexport function sliderUpdate(ref) {
var fs = ref.getElementsByTagName('fluent-slider')[0];
// fixes issue where you can't reset value programmatically
fs.value = fs.attributes['value'].value;
// fixes issue where the value indicator is not redrawn when either the min or max is changed
fs.setThumbPositionForOrientation(fs.direction);
} If you are using the folder layout from the fluentblazor template, place the first two files in the Components folder. Place the javascript file directly in the wwwroot folder. Change all |
Nice one Gary! I think we can add that to the regular slider in the lib. Fancy doing a PR for that? |
Sure 😄. I was hesitating suggesting a PR until I could verify the root cause. My adhoc preliminary testing of the |
* redraws thumb for slider when min or max changes * allows the slider value to be changed programmatically --------- Co-authored-by: Vincent Baaij <[email protected]>
Fixed with PR mentioned above. Will be in next release. Closing this. |
* redraws thumb for slider when min or max changes * allows the slider value to be changed programmatically --------- Co-authored-by: Vincent Baaij <[email protected]>
🐛 Bug Report
I have a Blazor app that I am using to display electrical usage over time. On my page, I have 4 sliders. 2 represent the years associated with the data and the other 2 represent the months. These are used for min/max. When I drag the start year, I want the min option for end year to be no smaller than the selected start year. Same goes for Start/end month.
The underlying selected (bound) values are correct, the display of the slider bar is what does not line up.
💻 Repro or Code Sample
This is a page I created to repro this issue.
This is what the output looks like
When I slide the To Month to 6 The from month's max value changes to 6 and the steps reflect properly.
But when I then change the From month to 5, the To Month slider stays pinned to middle of the line, but the steps update to reflect the correct choices.
When I try to slide the To Month again, it jumps to the step that it's closest to (in my example, between 8 and 9, and I then have to move the slider again back to 6 for both sliders to look correct.
But, if I again, change the From Month back to 1, the To Month no longer lines up as expected.
🤔 Expected Behavior
Both the slider indicator and the steps should be reflecting the same scale/numbers
😯 Current Behavior
Steps do get updated, but bar and button/thumb does not chanage.
💁 Possible Solution
When the Min/Max values are dependent on flexible values, the position should render last.
🔦 Context
🌍 Your Environment
The text was updated successfully, but these errors were encountered: