Skip to content

Conversation

IGx89
Copy link
Contributor

@IGx89 IGx89 commented Jun 10, 2025

Describe the PR

BLink and BButton have an icon prop which adds an icon-link class onto the element, enhancing their appearance when an icon is present (docs). BDropdown (and components that extend it, such as BNavItemDropdown) wraps a BButton but provides no way to set the icon prop on it nor add custom classes. This PR adds the icon prop to BDropdown (and by extension BNavItemDropdown), allowing the icon prop to be set on the nested BButton.

Small replication

    <BNavbarNav>
      <BNavItemDropdown :icon="true">
        <template #button-content>
          <svg
            xmlns="http://www.w3.org/2000/svg"
            width="16"
            height="16"
            fill="currentColor"
            class="bi bi-person-circle"
            viewBox="0 0 16 16"
          >
            <path d="M11 6a3 3 0 1 1-6 0 3 3 0 0 1 6 0" />
            <path
              fill-rule="evenodd"
              d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8m8-7a7 7 0 0 0-5.468 11.37C3.242 11.226 4.805 10 8 10s4.757 1.225 5.468 2.37A7 7 0 0 0 8 1"
            />
          </svg>
          <span>User</span>
        </template>
        <BDropdownItem>Logout</BDropdownItem>
      </BNavItemDropdown>
    </BNavbarNav>

Before:
image

After:
image

PR checklist

What kind of change does this PR introduce? (check at least one)

  • Bugfix 🐛 - fix(...)
  • Feature - feat(...)
  • ARIA accessibility - fix(...)
  • Documentation update - docs(...)
  • Other (please describe)

The PR fulfills these requirements:

  • Pull request title and all commits follow the Conventional Commits convention or has an override in this pull request body This is very important, as the CHANGELOG is generated from these messages, and determines the next version type. Pull requests that do not follow conventional commits or do not have an override will be denied

Summary by CodeRabbit

  • New Features

    • Added an option to display an icon on the main button of dropdown components.
  • Tests

    • Added tests to verify the default and custom behavior of the new icon option in dropdown components.
  • Documentation

    • Updated documentation to describe the new icon option for dropdown components.

Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

coderabbitai bot commented Jun 10, 2025

Walkthrough

A new icon prop was introduced to the BDropdown and BNavItemDropdown components, allowing consumers to control an icon attribute on the dropdown's main button. The prop is defined in the components, added to their TypeScript props interfaces, included in the shared dropdown props object, and covered by new unit tests verifying its default and explicit values.

Changes

File(s) Change Summary
packages/bootstrap-vue-next/src/components/BDropdown/BDropdown.vue, packages/bootstrap-vue-next/src/components/BNav/BNavItemDropdown.vue Added icon prop (default false) to components, bound to main button's icon attribute in BDropdown.
packages/bootstrap-vue-next/src/types/ComponentProps.ts, apps/docs/src/utils/dropdown-common.ts Added icon?: boolean to BDropdownProps interface and icon property to shared dropdownProps object.
packages/bootstrap-vue-next/src/components/BDropdown/dropdown.spec.ts Added tests for default and explicit icon prop behavior in BDropdown.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant BDropdown
    participant BButton

    User->>BDropdown: Render with or without icon prop
    BDropdown->>BButton: Pass icon prop (true/false)
    BButton-->>User: Render button with icon attribute accordingly
Loading

Poem

A dropdown now with icon flair,
A button shines with style to spare.
Tests ensure it's set just right,
False by day, true by night.
With code so neat and hops so spry—
This bunny gives a happy sigh! 🐰✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 90c5742 and c489338.

📒 Files selected for processing (1)
  • packages/bootstrap-vue-next/src/components/BNav/BNavItemDropdown.vue (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/bootstrap-vue-next/src/components/BNav/BNavItemDropdown.vue
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: build
  • GitHub Check: test-lint
  • GitHub Check: test-unit

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.
    • @coderabbitai modularize this function.
  • 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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 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: 0

🧹 Nitpick comments (2)
packages/bootstrap-vue-next/src/types/ComponentProps.ts (1)

1198-1206: icon prop correctly exposed but missing JSDoc / comment explaining intent

The new optional icon?: boolean flag for BDropdownProps is perfectly fine from a type-safety standpoint.
Consider adding a one-liner JSDoc (similar to noCaret, noShift, …) so that IDE tooltips and generated documentation clearly tell users that the value is forwarded to the nested BButton and triggers the .icon-link styling.

packages/bootstrap-vue-next/src/components/BDropdown/BDropdown.vue (1)

19-23: Forwarding icon unconditionally may produce unwanted styling on caret buttons

props.icon is forwarded to the first BButton regardless of split mode.
When split === false, that first button is the toggle button with the caret. Enabling icon in that case adds the .icon-link class, potentially clashing with the caret styling and producing a visual artefact.

-      :icon="props.icon"
+      :icon="!props.split ? false : props.icon"

This keeps the current behaviour for split buttons (where the first button is content-only) while avoiding accidental styling on plain toggles.
If you intentionally want the .icon-link class on the toggle button, feel free to ignore.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a7c66f1 and 47d73a7.

📒 Files selected for processing (3)
  • packages/bootstrap-vue-next/src/components/BDropdown/BDropdown.vue (2 hunks)
  • packages/bootstrap-vue-next/src/components/BDropdown/dropdown.spec.ts (1 hunks)
  • packages/bootstrap-vue-next/src/types/ComponentProps.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: test-unit
  • GitHub Check: test-lint
  • GitHub Check: build
🔇 Additional comments (2)
packages/bootstrap-vue-next/src/components/BDropdown/BDropdown.vue (1)

118-121: Prop default wired up correctly – nice

The new icon default (false) is set in _props, guaranteeing deterministic behaviour even when useDefaults overrides are present.

packages/bootstrap-vue-next/src/components/BDropdown/dropdown.spec.ts (1)

257-270: Tests cover default & truthy cases – good addition

Both edge cases (false by default and explicit true) are asserted, preventing regressions.
No further action required.

Copy link

pkg-pr-new bot commented Jun 10, 2025

bsvn-vite-ts

npm i https://pkg.pr.new/bootstrap-vue-next/bootstrap-vue-next@2746
npm i https://pkg.pr.new/bootstrap-vue-next/bootstrap-vue-next/@bootstrap-vue-next/nuxt@2746

commit: c489338

@xvaara
Copy link
Contributor

xvaara commented Jun 10, 2025

Add the default icon: false to the BNavItemDropdown.vue also.

@IGx89
Copy link
Contributor Author

IGx89 commented Jun 10, 2025

Add the default icon: false to the BNavItemDropdown.vue also.

@xvaara thanks, done

@xvaara xvaara merged commit 018daa5 into bootstrap-vue-next:main Jun 11, 2025
5 checks passed
@github-actions github-actions bot mentioned this pull request Jun 11, 2025
xvaara added a commit to xvaara/bootstrap-vue-next that referenced this pull request Jul 29, 2025
* upstream/main:
  docs: clean up css selector
  docs: fix on-this-page when examples use header tags
  docs(migration): add component aliases guidelines (bootstrap-vue-next#2771)
  chore: upgrade dependencies and address all lint warnings (bootstrap-vue-next#2785)
  chore: release main (bootstrap-vue-next#2769)
  fix(BDropdown): prevent hydration warning in nuxt production mode (bootstrap-vue-next#2768)
  docs(BTabs): Updates based on v-model changes (bootstrap-vue-next#2760)
  docs(table): fix missing anchor in `BTableLite` and `BTableSimple` links (bootstrap-vue-next#2759)
  docs(BFormRating): Parity pass (bootstrap-vue-next#2749)
  docs: fix typo in breadcrumb documentation (bootstrap-vue-next#2756)
  docs: Fix empty-text and empty-filtered-text description as they require show-empty to be set (bootstrap-vue-next#2755)
  fix InputGroupXPend.vue
  chore: release main (bootstrap-vue-next#2748)
  feat: implement BFormRating component (bootstrap-vue-next#2744)
  chore: release main
  fix(BLink): move active class to BNavItem (bootstrap-vue-next#2747)
  feat(BDropdown): allow setting icon prop on nested BButton (bootstrap-vue-next#2746)
  fix(BToast): close BToast correctly if modelValue is changed from number to false (bootstrap-vue-next#2745)
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.

3 participants