Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Apr 17, 2025

Link issues

fixes #5839

Summary By Copilot

This pull request introduces a new feature to the Tab component, enabling or disabling the looping behavior when switching between tabs. It also includes updates to localization files, documentation, and the project version.

Feature Enhancements:

  • Added IsLoopSwitchTabItem Parameter to Tab Component:
    • Introduced a new boolean parameter IsLoopSwitchTabItem to control whether tabs loop when switching. Defaults to true.
    • Updated the ClickPrevTab and ClickNextTab methods to respect the IsLoopSwitchTabItem setting, preventing looping when set to false. [1] [2]

Localization Updates:

  • English Localization (en-US.json):
    • Added a new description for the IsLoopSwitchTabItem feature in the tabs documentation.
    • Added a localized string for TabAttIsLoopSwitchTabItem.
  • Chinese Localization (zh-CN.json):
    • Updated the description for the IsLoopSwitchTabItem feature in the tabs documentation.
    • Added a localized string for TabAttIsLoopSwitchTabItem.

Documentation and Metadata:

  • Attribute List Update:
    • Added IsLoopSwitchTabItem to the attributes list in Tabs.razor.cs.
  • Project Version Update:
    • Incremented the project version to 9.5.8-beta01 in BootstrapBlazor.csproj.

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Add a new parameter to control tab switching behavior, allowing users to disable tab looping

New Features:

  • Introduce IsLoopSwitchTabItem parameter to control whether tabs can loop when reaching the first or last tab

Enhancements:

  • Modify tab navigation methods to respect the new looping control parameter
  • Update component documentation to include the new parameter

Documentation:

  • Add documentation for the new IsLoopSwitchTabItem parameter in attribute descriptions

@ArgoZhang ArgoZhang requested a review from Copilot April 17, 2025 04:56
@bb-auto bb-auto bot added the enhancement New feature or request label Apr 17, 2025
@bb-auto bb-auto bot added this to the v9.5.0 milestone Apr 17, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Apr 17, 2025

Reviewer's Guide by Sourcery

This pull request introduces the IsLoopSwitchTabItem parameter to the Tab component, allowing users to control whether tab switching loops. The implementation involves modifying the ClickPrevTab and ClickNextTab methods to respect this parameter. Additionally, localization files and the attribute list have been updated to reflect this new feature, and the project version has been incremented.

Sequence diagram for ClickPrevTab with IsLoopSwitchTabItem = false

sequenceDiagram
    participant Tab
    Tab->>Tab: index--
    alt index < 0
        Tab->>Tab: IsLoopSwitchTabItem == false
        Tab-->>Tab: return
    else index >= 0
        Tab->>Tab: ClickTabToNavigation == false
        Tab->>Tab: TabItems[index].SetActive(false)
    end
Loading

Sequence diagram for ClickNextTab with IsLoopSwitchTabItem = false

sequenceDiagram
    participant Tab
    Tab->>Tab: index++
    alt index + 1 > TabItems.Count
        Tab->>Tab: IsLoopSwitchTabItem == false
        Tab-->>Tab: return
    else index + 1 <= TabItems.Count
        Tab->>Tab: ClickTabToNavigation == false
        Tab->>Tab: item.SetActive(false)
    end
Loading

File-Level Changes

Change Details Files
Introduced a new boolean parameter IsLoopSwitchTabItem to the Tab component to control the looping behavior when switching between tabs.
  • Added IsLoopSwitchTabItem parameter with a default value of true.
  • Modified ClickPrevTab and ClickNextTab methods to respect the IsLoopSwitchTabItem setting.
  • When IsLoopSwitchTabItem is set to false, the tab switching will not loop back to the beginning or end.
src/BootstrapBlazor/Components/Tab/Tab.razor.cs
Updated localization files to include descriptions for the new IsLoopSwitchTabItem parameter.
  • Added a new description for the IsLoopSwitchTabItem feature in the English localization file.
  • Added a localized string for TabAttIsLoopSwitchTabItem in the English localization file.
  • Updated the description for the IsLoopSwitchTabItem feature in the Chinese localization file.
  • Added a localized string for TabAttIsLoopSwitchTabItem in the Chinese localization file.
src/BootstrapBlazor.Server/Locales/en-US.json
src/BootstrapBlazor.Server/Locales/zh-CN.json
Updated the attribute list to include the new IsLoopSwitchTabItem parameter.
  • Added IsLoopSwitchTabItem to the attributes list.
src/BootstrapBlazor.Server/Components/Samples/Tabs.razor.cs
Incremented the project version.
  • Incremented the project version to 9.5.8-beta01.
src/BootstrapBlazor/BootstrapBlazor.csproj

Assessment against linked issues

Issue Objective Addressed Explanation
#5839 Add a parameter to the Tab component to control whether tab switching loops.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 2 out of 5 changed files in this pull request and generated no comments.

Files not reviewed (3)
  • src/BootstrapBlazor.Server/Locales/en-US.json: Language not supported
  • src/BootstrapBlazor.Server/Locales/zh-CN.json: Language not supported
  • src/BootstrapBlazor/BootstrapBlazor.csproj: Language not supported
Comments suppressed due to low confidence (2)

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

  • [nitpick] Consider updating the XML summary comment for 'IsLoopSwitchTabItem' to more clearly state its purpose, e.g. 'Gets or sets whether tab switching should loop when navigating beyond the first or last tab.'
/// Gets or sets whether auto reset tab item index. Default is true.

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

  • [nitpick] Consider refactoring the index boundary check to 'if (index >= TabItems.Count)' for clarity and to maintain consistency with the range check in ClickPrevTab.
if (index + 1 > TabItems.Count)

sourcery-ai[bot]
sourcery-ai bot previously approved these changes Apr 17, 2025
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ArgoZhang - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding a sample to demonstrate the new IsLoopSwitchTabItem functionality.
  • Good job on including localization for the new parameter.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov
Copy link

codecov bot commented Apr 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (2cc46ca) to head (baaa374).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #5844   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          660       660           
  Lines        30125     30136   +11     
  Branches      4255      4257    +2     
=========================================
+ Hits         30125     30136   +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ArgoZhang ArgoZhang merged commit d1579e1 into main Apr 17, 2025
6 checks passed
@ArgoZhang ArgoZhang deleted the feat-tab branch April 17, 2025 05:23
ArgoZhang added a commit that referenced this pull request Apr 17, 2025
… behavior (#5844)

* feat: 增加 IsAutoLoopTabItem 参数

* doc: 更新文档

* chore: bump version 9.5.8-beta01

* test: 增加单元测试
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(Tab): 增加Tab上下标签切换时,是否可以循环参数控制

2 participants