question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

b-tabs: be able to get active tab title

See original GitHub issue

Is your feature request related to a problem? Please describe…

Hi, we need to load a component only when a b-tab is active. A solution to do this would be

<b-tabs v-model="tabIndex" >
<b-tab title="abc">...</b-tab>
...
<b-tab title="xyz">
<my-component v-if="tabIndex == 7"></my-component>
</b-tab>

Problem: The number of tabs vary dynamically, and we can’t tell at runtime which number is the proper tabIndex. But we know the title is “xyz”

Request: Be able to get the active tab title from tabIndex, or have another way to determine the current tab title.

Describe the solution you’d like

<b-tabs @change="tabChange" >

tabChange(e) never triggers. Would expect that to trigger and have the index & title in event properties.

OR

<b-tabs ref="tabs" >

and have something like this.$refs.tabs.getTitle(tabIndex)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
tmorehousecommented, Nov 7, 2019

One can also make individual <b-tab> components lazy via the lazy prop, which when set doesn’t mount the content of the <b-tab> until it is shown/activated, and will be un-mounted when the tab is deactivated/hidden.

https://bootstrap-vue.js.org/docs/components/tabs#comp-ref-b-tab

<b-tabs>
  <b-tab title="abc">
    <!-- this component will always be mounted -->
    <my-abc-component></my-abc-component>
  </b-tab>
  <b-tab title="xyz" lazy>
    <!-- this component will not be mounted until this tab is shown -->
    <!-- and will be un-mounted when hidden -->
    <my-xyz-component></my-xyz-component>
  </b-tab>
</b-tabs>

One can also make all tab’s lazy by setting the lazy prop on the parent <b-tabs> component

https://bootstrap-vue.js.org/docs/components/tabs#comp-ref-b-tabs

<b-tabs lazy>
  <b-tab title="abc">
    <!-- this component will not be mounted until this tab is shown -->
    <!-- and will be un-mounted when hidden -->
    <my-abc-component></my-abc-component>
  </b-tab>
  <b-tab title="xyz">
    <!-- this component will not be mounted until this tab is shown -->
    <!-- and will be un-mounted when hidden -->
    <my-xyz-component></my-xyz-component>
  </b-tab>
</b-tabs>
1reaction
mariusacommented, Nov 7, 2019

@tmorehouse I made a pull request. It’s mainly with your explanatory comment 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tabs | Components - BootstrapVue
If you want to add custom content to tab title, like HTML code, icons, or another non-interactive Vue component, this possible by using...
Read more >
"react-tabs" is there any way to get the text of the active tab (or ...
Was just going through react tabs, instead of onClick , use can use, focusTabOnClick and pass state accordingly .
Read more >
Expose Current Tab Title - Feedback and Feature Requests
Expose Current Tab Title. At the moment, you can't get the currently active tab with code, the Title property of the tabs is...
Read more >
chrome.tabs - Chrome Developers
# Get the current tab. This example demonstrates how an extension's service worker can retrieve the active tab from the currently-focused window (or...
Read more >
Working with the Tabs API - Mozilla - MDN Web Docs
"tabs" permission is needed to access the Tab.url , Tab.title ... Where you want information about the current tab only, you can get...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found