Skip to content

Commit bd97e07

Browse files
committed
feat: 增加 IsAutoLoopTabItem 参数
1 parent 2cc46ca commit bd97e07

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

src/BootstrapBlazor/Components/Tab/Tab.razor.cs

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ public partial class Tab : IHandlerException
139139
[Parameter]
140140
public bool ShowNavigatorButtons { get; set; } = true;
141141

142+
/// <summary>
143+
/// Gets or sets whether auto reset tab item index. Default is true.
144+
/// </summary>
145+
[Parameter]
146+
public bool IsAutoLoopTabItem { get; set; } = true;
147+
142148
/// <summary>
143149
/// 获得/设置 是否显示活动标签 默认为 true 显示
144150
/// </summary>
@@ -650,7 +656,14 @@ public void ClickPrevTab()
650656
index--;
651657
if (index < 0)
652658
{
653-
index = TabItems.Count - 1;
659+
if (IsAutoLoopTabItem)
660+
{
661+
index = TabItems.Count - 1;
662+
}
663+
else
664+
{
665+
return;
666+
}
654667
}
655668

656669
if (!ClickTabToNavigation)
@@ -683,15 +696,22 @@ public void ClickNextTab()
683696
var index = TabItems.IndexOf(item);
684697
if (index < TabItems.Count)
685698
{
686-
if (!ClickTabToNavigation)
699+
index++;
700+
if (index + 1 > TabItems.Count)
687701
{
688-
item.SetActive(false);
702+
if (IsAutoLoopTabItem)
703+
{
704+
index = 0;
705+
}
706+
else
707+
{
708+
return;
709+
}
689710
}
690711

691-
index++;
692-
if (index + 1 > TabItems.Count)
712+
if (!ClickTabToNavigation)
693713
{
694-
index = 0;
714+
item.SetActive(false);
695715
}
696716

697717
item = TabItems[index];

0 commit comments

Comments
 (0)