Skip to content

Conversation

msynk
Copy link
Member

@msynk msynk commented Aug 3, 2025

closes #11225

Summary by CodeRabbit

  • New Features

    • Added support for customizable URL matching modes (Exact, Prefix, Regex, Wildcard) in navigation components, allowing more flexible active state detection for navigation items.
    • Introduced new parameters to navigation panels and options for specifying matching behavior.
    • Enhanced demo and documentation to showcase and explain the new URL matching options.
  • Improvements

    • Iconography page now allows users to click an icon to copy its name to the clipboard, with an instructional note added for clarity.
  • Style

    • Adjusted spacing in the icon search box area for a cleaner layout.

Copy link

coderabbitai bot commented Aug 3, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

A new flexible URL matching feature is introduced for navigation components, enabling support for exact, prefix, regex, and wildcard route matching. This feature is implemented through a new BitNavMatch enum and corresponding parameters in navigation-related components. Demo and documentation files are updated to reflect and showcase the new matching options.

Changes

Cohort / File(s) Change Summary
Nav Matching Core Implementation
src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNavMatch.cs, src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNav.razor.cs, src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNavItem.cs, src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNavOption.razor.cs, src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNavNameSelectors.cs
Introduced BitNavMatch enum for URL matching strategies. Added Match parameter/property to BitNav, BitNavItem, BitNavOption, and BitNavNameSelectors. Updated item selection logic to use flexible matching (exact, prefix, regex, wildcard). Enhanced XML docs.
NavPanel Integration
src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor, src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor.cs
Added NavMatch parameter to BitNavPanel and bound it to the inner BitNav's Match parameter.
Demo/Documentation Updates
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/NavPanel/BitNavPanelDemo.razor.cs, src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Navs/Nav/BitNavDemo.razor.cs
Added documentation and parameter table entries for the new Match/NavMatch parameter and the BitNavMatch enum, describing each matching mode.
Iconography Page: Usability Enhancement
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/IconographyPage.razor, src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/IconographyPage.razor.cs, src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/IconographyPage.razor.scss
Improved iconography page by adding a clipboard copy feature for icon names, updating UI instructions, and removing the search box's bottom margin.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant BitNavPanel
    participant BitNav
    participant BitNavItem

    User->>BitNavPanel: Navigates to a route
    BitNavPanel->>BitNav: Passes NavMatch parameter
    BitNav->>BitNavItem: Checks Match property for each item
    BitNav->>BitNav: Uses Match/Item.Match to select active item (Exact/Prefix/Regex/Wildcard)
    BitNav-->>BitNavPanel: Updates selected state
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Assessment against linked issues

Objective Addressed Explanation
Support partial route matches in a BitNavItem (#11225)
Allow configuration of match mode (exact, prefix, etc.) per item and globally (#11225)
Update documentation and demos to reflect new matching options (#11225)

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Add clipboard copy feature for icon names (src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/IconographyPage.razor, .razor.cs, .razor.scss) This usability enhancement is unrelated to the navigation matching objectives and not referenced in the linked issue.

Poem

A rabbit hopped down the navigation lane,
Now wildcards and prefixes ease the user's pain.
With matches exact, or patterns so sly,
The nav stays on track as the routes pass by.
And icons now copy with a click—
Oh, what a clever, code-happy trick!
🐇✨

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🧹 Nitpick comments (2)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/IconographyPage.razor (1)

42-42: Consider adding user feedback for clipboard operations.

While the click handler implementation is correct, users may not realize when the copy operation succeeds or fails. Consider adding visual feedback (e.g., toast notification, temporary checkmark, or tooltip) to confirm the clipboard operation.

-<div class="icon-box" @onclick="async () => await CopyToClipboard(icon)">
+<div class="icon-box" @onclick="async () => await CopyToClipboard(icon)" title="Click to copy '@icon' to clipboard">

Additionally, consider updating the CopyToClipboard method to show user feedback upon successful copy.

src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNavMatch.cs (1)

1-27: LGTM! Comprehensive enum design addresses the PR objectives.

The BitNavMatch enum is well-designed with:

  • Four matching modes covering common URL matching scenarios
  • Clear XML documentation for each mode
  • Proper naming conventions and namespace placement
  • Addresses the original issue's need for partial route matching (via Prefix mode)

Consider performance implications for Regex mode in high-frequency navigation scenarios.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Knowledge Base: Disabled due to Reviews > Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between ac61823 and f835651.

📒 Files selected for processing (12)
  • src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor (1 hunks)
  • src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor.cs (1 hunks)
  • src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNav.razor.cs (4 hunks)
  • src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNavItem.cs (1 hunks)
  • src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNavMatch.cs (1 hunks)
  • src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNavNameSelectors.cs (1 hunks)
  • src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNavOption.razor.cs (1 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/NavPanel/BitNavPanelDemo.razor.cs (3 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Navs/Nav/BitNavDemo.razor.cs (2 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/IconographyPage.razor (2 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/IconographyPage.razor.cs (3 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/IconographyPage.razor.scss (0 hunks)
💤 Files with no reviewable changes (1)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/IconographyPage.razor.scss
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build and test
🔇 Additional comments (23)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/IconographyPage.razor.cs (3)

12-12: LGTM! Proper dependency injection.

The IJSRuntime injection using [AutoInject] follows the established pattern in the codebase.


40-43: CopyToClipboard extension method verified

I located the CopyToClipboard extension in src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Extensions/IJSRuntimeExtensions.cs, where it’s defined as:

public static async Task CopyToClipboard(this IJSRuntime jsRuntime, string content)
{
    await jsRuntime.InvokeVoid("copyToClipboard", content);
}

No further changes are needed—this satisfies the usage in IconographyPage.razor.cs.


12-12: LGTM: Proper dependency injection.

The IJSRuntime injection using [AutoInject] follows the expected pattern for the framework.

src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/IconographyPage.razor (1)

28-30: Clear user instruction added.

The instructional text effectively communicates the new clipboard functionality to users.

src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor (1)

130-130: LGTM! Clean parameter forwarding.

The addition of Match="NavMatch" correctly forwards the navigation panel's URL matching behavior to the internal BitNav component, following standard Blazor parameter binding patterns.

src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNavOption.razor.cs (1)

89-92: LGTM! Well-implemented parameter addition.

The Match parameter is properly implemented with:

  • Correct nullable BitNavMatch? type for optional behavior
  • Appropriate [Parameter] attribute for Blazor binding
  • Clear XML documentation describing the URL matching behavior
src/BlazorUI/Bit.BlazorUI.Extras/Components/NavPanel/BitNavPanel.razor.cs (1)

148-151: LGTM! Clean parameter implementation.

The NavMatch parameter is well-implemented with:

  • Proper [Parameter] attribute for Blazor component binding
  • Nullable type for optional behavior specification
  • Clear documentation explaining global URL matching behavior
  • Logical naming that distinguishes panel-level parameter from component-level
src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNavNameSelectors.cs (4)

6-116: LGTM! Excellent documentation improvements.

The systematic addition of <see cref="BitNavItem.PropertyName"/> references to all XML documentation comments significantly improves code discoverability and IntelliSense support for developers.


75-78: LGTM! Well-implemented Match property addition.

The new Match property correctly follows the established patterns for type definition, initialization, and documentation. This addition properly supports the URL matching feature described in the PR objectives.


6-6: LGTM! Excellent documentation improvements.

The XML documentation updates consistently add proper cross-references to the corresponding BitNavItem properties using <see cref="..."/> tags, improving the developer experience and code documentation quality.

Also applies to: 11-11, 16-16, 21-21, 26-26, 31-31, 36-36, 41-41, 46-46, 51-51, 56-56, 61-61, 66-66, 71-71, 81-81, 86-86, 91-91, 96-96, 101-101, 106-106, 111-111, 116-116


75-78: LGTM! New Match property follows established patterns.

The new Match property is properly implemented following the same pattern as other properties in the class, with appropriate XML documentation and default initialization referencing BitNavItem.Match.

src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Navs/Nav/BitNavDemo.razor.cs (4)

146-153: LGTM! Well-documented Match parameter.

The new Match parameter is properly defined with appropriate type, default value, and clear description. The reference link to the enum documentation enhances usability.


938-969: LGTM! Comprehensive BitNavMatch enum documentation.

The enum definition provides clear, detailed descriptions for all four matching modes (Exact, Prefix, Regex, Wildcard). The descriptions effectively explain when each mode should be used, which will help developers choose the appropriate matching behavior.


146-153: LGTM! Well-documented Match parameter addition.

The new Match parameter is properly defined with clear documentation describing its purpose for global URL matching behavior. The link reference to the enum documentation enhances usability.


938-969: LGTM! Comprehensive BitNavMatch enum documentation.

The enum definitions are well-structured with clear descriptions for each matching strategy:

  • Exact: Standard exact URL matching
  • Prefix: Supports hierarchical navigation patterns
  • Regex: Advanced pattern matching capabilities
  • Wildcard: User-friendly pattern matching with * and ? support

This provides developers with flexible options for different navigation scenarios.

src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Extras/NavPanel/BitNavPanelDemo.razor.cs (2)

546-577: LGTM! Consistent enum documentation.

The BitNavMatch enum definition is identical to the one in BitNavDemo, ensuring consistent documentation across components. While this creates some duplication, it maintains self-contained documentation for each demo component.


546-577: LGTM! Consistent enum documentation.

The BitNavMatch enum is properly documented with the same comprehensive descriptions as in the main Nav demo, ensuring consistency across the component documentation.

src/BlazorUI/Bit.BlazorUI/Components/Navs/Nav/BitNav.razor.cs (6)

1-2: LGTM! Appropriate imports for new functionality.

The new using statements for System.Text.RegularExpressions and Microsoft.AspNetCore.Components.Routing are correctly added to support the URL matching functionality.


121-124: LGTM! Well-defined Match parameter.

The Match parameter is properly implemented with clear documentation explaining its purpose for global URL matching behavior. The nullable type appropriately allows for optional configuration.


917-937: LGTM! Consistent implementation pattern.

The GetMatch method follows the established pattern used by other property accessor methods in the class, properly handling BitNavItem, BitNavOption, and NameSelectors scenarios with appropriate fallback logic.


1-2: LGTM! Necessary using statements for new functionality.

The new using statements support the regex and navigation routing functionality required for the URL matching feature.


121-124: LGTM! Well-documented Match parameter.

The new Match parameter is properly defined as nullable and includes clear documentation describing its purpose for global URL matching behavior.


917-937: LGTM! GetMatch method follows established patterns.

The GetMatch method correctly follows the same pattern as other property getter methods in the class, checking item types in order and falling back to NameSelectors when available.

@msynk msynk merged commit de2bfb6 into bitfoundation:develop Aug 4, 2025
3 checks passed
@msynk msynk deleted the 11225-blazorui-nav-match branch August 4, 2025 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support partial route matches in a BitNavItem
1 participant