From bb675ee040bcba3343728c3c9c1ffb9d495fb6e8 Mon Sep 17 00:00:00 2001 From: Vladimir Enchev Date: Tue, 5 Nov 2024 09:45:48 +0200 Subject: [PATCH] Fixed Carousel out of range exception when navigating to out of range index Close #1769 #1770 --- Radzen.Blazor/RadzenCarousel.razor.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Radzen.Blazor/RadzenCarousel.razor.cs b/Radzen.Blazor/RadzenCarousel.razor.cs index 35784e85b04..fb5324e5fcd 100644 --- a/Radzen.Blazor/RadzenCarousel.razor.cs +++ b/Radzen.Blazor/RadzenCarousel.razor.cs @@ -101,9 +101,9 @@ async Task Next() async Task GoTo(int index) { - if (selectedIndex != index) + if (index >= 0 && index <= items.Count - 1 && selectedIndex != index) { - selectedIndex = index == items.Count ? 0 : index; + selectedIndex = index; await SelectedIndexChanged.InvokeAsync(selectedIndex); await Change.InvokeAsync(selectedIndex); await JSRuntime.InvokeVoidAsync("Radzen.scrollCarouselItem", items[selectedIndex].element);