Skip to content

Tabs Component does not update selectedIndex if previously selected-Tab is removed from children #2798

Open
@i039666

Description

@i039666

Hi,

I have a Tabs component with 2 tabs. Here we dynamically show and hide tabs.

  1. User selects the 2nd tab => selectedIndex = 1
  2. Because of certain user action, We hide the 2nd selected tab. total tabs-count = 1
  3. Issue:- After this action 1st tab is not automatically selected
  4. Root Cause:- selectedIndex is still 1, which is out of boundary as tabs-count =1 .

Ideally end user expects the current available tab should be selected.

`getSelectedIndex() {
if( Number.isInteger(this.props.selectedIndex))
return this.props.selectedIndex;

        // Suggested fix, reset to 0 or update to defaultSelectionIndex
         return this.state.selectionIndex> this.getTabsCount() - 1 ? 0: this.state.selectionIndex;

`
Thanks,
Praveen

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