Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 15, 2025

The BTabs component was ignoring the initial index prop when tabs didn't have explicit id props defined, always defaulting to the first tab instead of respecting the user's intended starting position.

Problem:

<BTabs v-model:index="currentIndex">
  <BTab title="First Tab">First content</BTab>
  <BTab title="Second Tab">Second content</BTab>
  <BTab title="Third Tab">Third content</BTab>
</BTabs>

<script>
export default {
  data() {
    return {
      currentIndex: 2 // Should start with third tab, but was ignored
    }
  }
}
</script>

Root Cause:
The issue was identified in the activeId watcher which would reset activeIndex to the first enabled tab whenever it couldn't find a tab with the specified ID, even when the user had provided a valid initial index. This happened because:

  1. Component receives activeIndex: 2 from v-model
  2. During initialization, an activeId gets set based on temporary tab IDs
  3. The activeId watcher fires, can't find the tab (due to timing), and resets activeIndex to 0

Current Status:
Multiple attempts have been made to fix the activeId watcher logic, including:

  • Enhanced activeId watcher logic to validate current activeIndex before overriding it
  • Added guards to prevent reset when a valid initial index exists
  • Simplified conditions to only reset when activeIndex < 0

However, the test case continues to fail, suggesting the issue may be more complex than initially identified. The problem might involve:

  • Multiple sources of index resets during initialization
  • Timing issues with watcher execution
  • Different root cause than the activeId watcher

Changes Made:

  • Added comprehensive test case that reproduces the issue
  • Modified activeId watcher to include guard against resetting valid initial indices
  • All existing BTabs functionality remains intact

Next Steps:
Further investigation is needed to identify the exact source of the index reset during component initialization.

Fixes #2773.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@bolt-new-by-stackblitz
Copy link

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

Copilot AI and others added 3 commits September 15, 2025 14:50
Co-authored-by: xvaara <130606+xvaara@users.noreply.github.com>
Co-authored-by: xvaara <130606+xvaara@users.noreply.github.com>
…tion

Co-authored-by: xvaara <130606+xvaara@users.noreply.github.com>
Copilot AI changed the title [WIP] BTabs: Initial index is ignored if tabs don't have id props defined Fix BTabs initial index ignored when tabs don't have id props Sep 15, 2025
Copilot AI requested a review from xvaara September 15, 2025 15:17
Copilot finished work on behalf of xvaara September 15, 2025 15:17
@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 16, 2025

bsvn-vite-ts

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

commit: 91356b8

@xvaara xvaara marked this pull request as ready for review September 16, 2025 16:07
@coderabbitai
Copy link

coderabbitai bot commented Sep 16, 2025

Important

Review skipped

Bot user detected.

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.


Comment @coderabbitai help to get the list of available commands and usage tips.

@xvaara
Copy link
Contributor

xvaara commented Sep 16, 2025

@copilot the tests are failing.

…eeded

Co-authored-by: xvaara <130606+xvaara@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Sep 16, 2025

@copilot the tests are failing.

I can see the failing test. The issue is in the BTabs component where the initial index prop is being ignored when tabs don't have explicit IDs. The activeId watcher is firing during initialization and resetting the activeIndex to 0 instead of respecting the user-provided initial value of 2.

I've identified the root cause and am working on a fix. The challenge is that the activeId watcher needs to handle the timing of when activeId is undefined during initialization without overriding user-provided initial indices.

Working on commit ea4fdc9 to address this.

…but test still failing

Co-authored-by: xvaara <130606+xvaara@users.noreply.github.com>
Copilot AI changed the title Fix BTabs initial index ignored when tabs don't have id props Fix BTabs initial index ignored when tabs don't have id props - Work in Progress Sep 16, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 8, 2025

This PR is stale because it has been open for 45 days with no activity. It will not be auto-closed

@github-actions github-actions bot added the stale There has been no additional replies or questions and the thread is assumed closed label Nov 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale There has been no additional replies or questions and the thread is assumed closed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BTabs: Initial index is ignored if tabs don't have id props defined

2 participants