Skip to content

Commit

Permalink
Fixed Carousel out of range exception when navigating to out of range…
Browse files Browse the repository at this point in the history
… index

Close #1769 #1770
  • Loading branch information
enchev committed Nov 5, 2024
1 parent 9b4aff7 commit bb675ee
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Radzen.Blazor/RadzenCarousel.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit bb675ee

Please sign in to comment.