Skip to content

Add toolbar dropdown support - #107

Open
albx wants to merge 6 commits into
mainfrom
feature/99-toolbar-dropdown-support
Open

albx wants to merge 6 commits into
mainfrom
feature/99-toolbar-dropdown-support

Conversation

@albx

@albx albx commented Sep 29, 2026

Copy link
Copy Markdown
Owner

This pull request introduces a new BitToolbarDropdownItem component to the toolbar system, enabling dropdown functionality directly within toolbars. It also refactors the toolbar item codebase to promote reusability and maintainability by extracting common logic into a new base class, BitToolbarItemBase. Several stories and usage examples are added to showcase the new dropdown capabilities, and sample pages are updated to utilize these improvements.

New Dropdown Functionality in Toolbar:

  • Added the BitToolbarDropdownItem component, allowing toolbar items to display dropdown menus with customizable content and badge support. (src/BitBlazor/Components/Toolbar/BitToolbarDropdownItem.razor [1] src/BitBlazor/Components/Toolbar/BitToolbarDropdownItem.razor.cs [2]
  • Updated the sample Pratiche.razor page to use the new dropdown for exporting data in various formats, with a corresponding handler method. (samples/BitBlazor.Sample/BitBlazor.Sample/Components/Pages/Pratiche.razor [1] [2]

Codebase Refactoring and Reusability:

  • Extracted common toolbar item logic and parameters (such as Label, IconName, badge handling, etc.) into a new abstract base class BitToolbarItemBase, now inherited by both BitToolbarItem and BitToolbarDropdownItem. (src/BitBlazor/Components/Toolbar/BitToolbarItemBase.cs [1] src/BitBlazor/Components/Toolbar/BitToolbarItem.razor [2] src/BitBlazor/Components/Toolbar/BitToolbarItem.razor.cs [3] [4] [5] [6]
  • Moved shared rendering logic (such as label CSS and badge rendering) from individual components into the base class for consistency and maintainability. (src/BitBlazor/Components/Toolbar/BitToolbarItem.razor src/BitBlazor/Components/Toolbar/BitToolbarItem.razorL30-L33)

Stories and Testing:

@albx albx linked an issue Sep 29, 2026 that may be closed by this pull request
@albx
albx requested a balanced review from Copilot September 29, 2026 17:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Disabled and active states, attribute forwarding, base-class conventions, and public documentation need correction.

Review effort: Balanced
Findings: 2 Medium severity · 1 Low severity

Open (3)
What changed in this PR

Adds dropdown actions to toolbars and extracts shared toolbar-item behavior.

Changes:

  • Introduces BitToolbarDropdownItem.
  • Adds shared BitToolbarItemBase.
  • Adds tests, stories, and a sample export menu.
File Description
BitToolbarTest.Rendering.razor Tests dropdown rendering and badges.
BitToolbarTest.Behaviors.cs Tests dropdown interactions.
BitToolbar.stories.razor Adds dropdown stories.
BitToolbarItemBase.cs Extracts shared item parameters and rendering logic.
BitToolbarItem.razor.cs Adopts the shared base.
BitToolbarItem.razor Uses shared rendering helpers.
BitToolbarDropdownItem.razor.cs Defines the dropdown API.
BitToolbarDropdownItem.razor Renders the dropdown activator and menu.
Pratiche.razor Demonstrates export actions.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/BitBlazor/Components/Toolbar/BitToolbarDropdownItem.razor Outdated
Comment thread src/BitBlazor/Components/Toolbar/BitToolbarItemBase.cs
Comment thread src/BitBlazor/Components/Toolbar/BitToolbarDropdownItem.razor.cs
@albx
albx marked this pull request as ready for review September 29, 2026 18:07
@albx
albx requested a balanced review from Copilot September 29, 2026 18:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The dropdown ignores its active state, lacks Escape dismissal from the activator, and its base class violates the component hierarchy convention.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
Resolved since last review (3)
Previously missed (2)

In code that hasn't changed since last review

Medium severity Apply Active state class to dropdown items

src/​BitBlazor/​Components/​Toolbar/​BitToolbarDropdownItem.razor.cs:42

Active is inherited and documented for BitToolbarDropdownItem, but this class builder never uses it, so Active="true" has no visual effect. Add the active class just as BitToolbarItem.ComputeLinkCssClass() does.

Medium severity Enable Escape key to close the open dropdown

src/​BitBlazor/​Components/​Toolbar/​BitToolbarDropdownItem.razor.cs:74

Escape is delegated to ActivatorContext.HandleKeyDownAsync, but that handler only handles ArrowDown/ArrowUp. Opening via click or keyboard activation leaves focus on this button, so Escape cannot dismiss the open menu. Add a close-aware Escape path to the dropdown context/component and cover it with a keyboard test.

| `Active` | `bool` | ✗ | `false` | When `true`, applies the active style to the item |
| `Disabled` | `bool` | ✗ | `false` | When `true`, disables the item and adds `aria-disabled="true"` |
| `BadgeCount` | `int?` | ✗ | `null` | A numeric badge count shown on the item; hidden when `null` or `0` |
| `BadgeLabel` | `string?` | ✗ | `null` | A text label shown next to the badge; displayed in different positions depending on `Size` |
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.

[FEATURE] Add Dropdown Support to BitToolbar Component

2 participants