8000 BTabs: can't set initial value · Issue #2705 · bootstrap-vue-next/bootstrap-vue-next · GitHub
[go: up one dir, main page]

Skip to content
BTabs: can't set initial value #2705
Closed
@afv

Description

@afv

Describe the bug

Hi,

I'm not being able to define the initial selected tab. Even if I change the value onMounted, it is reset to 0.

This was working on 0.28.6, and is broken since 0.29.1.
bootstrapvuenext-v0.28.6...bootstrapvuenext-v0.29.1

<template>
  <h3>selectedIndex: {{ selectedIndex }}</h3>
  <BTabs v-model="selectedIndex">
    <BTab title="0" />
    <BTab title="1" />
    <BTab title="2" />
    <BTab title="3" />
    <BTab title="4" />
  </BTabs>
</template>

<script setup>
import { onMounted, ref, watch } from "vue";
import { BTab, BTabs } from "bootstrap-vue-next";

const selectedIndex = ref(3);

onMounted(() => {
  selectedIndex.value = 3;
});

watch(
  selectedIndex,
  (val) => {
    console.log("selectedIndex", val);
  },
  { immediate: true }
);
</script>

Console output:

selectedIndex 3
selectedIndex 0
selectedIndex 3
selectedIndex 0

Reproduction

https://codesandbox.io/p/sandbox/ygkzlr

Used Package Manager

pnpm

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0