[b-tabs] not able to active a new tab added on fly
See original GitHub issueDescribe the bug
The problem was also indicated in this closed ticket https://github.com/bootstrap-vue/bootstrap-vue/issues/1378 but I suspect never was solved ( if it might be solved? ).
Basically after adding a new tab dynamically is not possible to activate this tab on fly.
I’m using v-model=“groups” what is a list of elements
I have tested with :
this.$nextTick(() => {
this.tabIndex = this.groups.length - 1;
});
and also with
Vue.nextTick().then(() => {
this.tabIndex = this.groups.length - 1;
});
Expected behavior
I success get it working with a timeout, but seems a not safe way for doing it:
setTimeout(() => {
this.tabIndex = this.groups.length - 1;
}, 400);
I would like to know if it is another version to get it running
Versions
Libraries:
- BootstrapVue: 2.0.0-rc.24
- Bootstrap: 4.3.1
- Vue: 2.6.6
Environment:
- Browser: Chrome
- Version: 75.0.3770.100 (Build oficial) (64 bits)
Demo link
Here is an old sample of the issue what is not working as expected: http://jsfiddle.net/cihkem/3apaaz4n/1/
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Chrome extension not automatically activating on new tab
When I open a new tab, the extension won't activate until I click on it. ... password is added dynamically. it just won't...
Read more >How can Chrome not automatically switch to new tab, when ...
1) select "open link in new background tab" from the context menu (second choice), 2) use middle-click on the link with your mouse;...
Read more >Use tabs in Chrome - Computer - Google Support
On your computer, open Chrome Chrome . · Click New tab New tab . · Right-click a tab and then select Add to...
Read more >Tab Activate
With Tab Activate, new tabs open immediately instead of in the background. To override Tab Activate and open a new tab in the...
Read more >Why can't I open a new Tab with the "Plus" sign or "Command ...
If I want to open a New Tab, I either press "Command T" or select "New Tab" from the File menu, or click...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@darkman97i I just remembered about another way you could know when the tab is ready to be activated.
<b-tabs>
emits the eventchanged
when tabs are added, removed, or re-ordered. You could listen to that event and update the v-model then, and you would no longer need the $nextTicks and requestAnimation frame.https://bootstrap-vue.js.org/docs/components/tabs#comp-ref-b-tabs-events
When you diagrammatically add a tab (i.e. with v-if, or similar), you can have the b-tab’s
active
prop set, which will activate the tab once it is discovered (assuming the new tab appears last)And after reviewing the code, I think you need a double nextTick + Request animation frame to set the new active tab index (via the v-model), to get around the delays required by the tab probing/disovery process:
Or if using the promise version of
$nextTick
(with async support):