Skip to content

Removing Open Tab #118

@maxsalven

Description

@maxsalven

My tabs are rendered from a prop (simplified example:tabs: ['Hi', 'There']).

If I delete a tab that is currently selected, another tab doesn't get selected/rendered, and it just shows no content. Rather than making a user have to deal with selectedIndex in this situation, it would be nice if the component automatically selected another tab (perhaps the first tab, or the tab prior to the deleted tab, would be sensible options). This allows me to keep my component stateless and simple.

<Tabs>
  <TabList>
    {tabs.map(content => (<Tab>{content}</Tab>)}
  </TabList>
  {tabs.map((content, index) => (
    <TabPanel>
      <div>
        {content} - <span onClick={() => this.deleteTab(index)}>Delete</span>
      </div>
    </TabPanel>
  )}
</Tabs>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions