Skip to content

Tabset is not resetting back, when first tab is removed. #872

@jav7zaid

Description

@jav7zaid

Describe the Bug

So, i was digging into Tabset for my project related work and observed that when you are on the first tab and try to remove it, the next available correct tab/panel doesn't gets selected.

So why is this happening?

As per my understanding, the observed attribute that triggers the onAttributeChange callback is the 'current-tab' property, and as we are on the first tab and trying to remove the same, there is no change in the old and new value, thats why the update doesn't happen.

Steps to Reproduce

Steps to reproduce the behavior:

  1. https://helixdesignsystem.github.io/helix-ui/components/tabset/
  2. Go to Dynamic Tabset Section
  3. Click on Remove First Button

Expected behavior

Should select the next available tab, similar to what is happening when you try to remove the last tab.

Screenshots

tabset

Environment

Please complete the following information:

  • Device: [e.g. Desktop, Laptop, iPhone6, etc.]
  • OS: [e.g. iOS]
  • Browser: [e.g. chrome, safari]
  • Version: [e.g. 22]

Additional Context

I can raise a PR as well, let me know.
How to fix this - docs/components/tabset/tabset-demo.js

Line no - 31 - check for currentTab value, when the updation occurs, seems to solve this issue.

// keep correct tab/panel pair open when a "tab" is added or when first tab is removed
if (this.autoUpdate || this.currentTab === 0) {
this.update();
}

This fix is just a workaround for demo and not a proper solution, but I am thinking of a proper use case here.
I know we could use update() function wherever we want to sync, but can this be handled as part of Tabset component ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions