carbon-design-system / carbon-components-vue

Vue implementation of the Carbon Design System
http://vue.carbondesignsystem.com
Apache License 2.0
609 stars 178 forks source link

[Question]: How to programmatically change tabs using IBM Carbon Design System with Vue? #1362

Closed ponessa closed 1 month ago

ponessa commented 2 years ago

Question for Carbon

I am an IBMer and have reached out in #carbon-components, who directed #carbon-vue, but have had no luck. At this point, I am not sure if I am missing something (the most probable option) or if there is a bug.

I need help programmatically changing Carbon/vue tabs. In the 1st tab (0), I want to be able click a button and bring the user to the 4th tab (3). In the template section I have the following:

<cv-tabs selected="1" aria-label="Tab navigation" ref="tabs" id="nav-tab">
    <cv-tab label="GETTING STARTED">
        ...
        <cv-button @click="changeTab">Go to JRS Navigator</cv-button>
    </cv-tab>
    <cv-tab label="TAXONOMY BASICS">
        ...
    </cv-tab>
    <cv-tab label="MANAGER GUIDANCE">
        ...
    </cv-tab>
    <cv-tab label="JRS NAVIGATOR">
        ... where I want the button to take me ...
    </cv-tab>
</cv-tabs>

In the methods section I define changeTab(). This pulls the cv-tabs VueComponent based on the ref="tabs", setting selected(3) does NOT switch the tabs, it only changes the selected tab to be the 4th tab (3) JRS NAVIGATOR (I.e., 4th tab has the blue bar under it), but the tab’s content is still the first tab (GETTING STARTED).

methods: {
    changeTab(){
        //this.$refs.tabs.navigateToTab(3)
        this.$refs.tabs.selected(3)
    },
    ...
}

Any ideas?

Code of Conduct

github-actions[bot] commented 3 months ago

This issue has been marked as stale because it has required additional info or a response from the author for over 14 days. When you get the chance, please comment with the additional info requested. Otherwise, this issue will be closed in 14 days.

github-actions[bot] commented 1 month ago

This issue has been closed because it has received no activity for 28 days.