Skip to content

The selected tab is not being set correctly [Controlled]. #7526

Open
@Nagendra7509

Description

Provide a general summary of the issue here

I am managing selectedTabId and items in the local state. When I dynamically add a new tab, I update the items list and set the new tab's ID as the selectedTabId. However, when selectedTabId changes, the onSelectionChange event is triggered with the ID of the first tab in the items list, causing the selectedTabId to revert to the first tab's ID.

🤔 Expected Behavior?

Set the newly created tab ID as the selectedTabId.

😯 Current Behavior

The ID of the first tab in the items list is being set as the selectedTabId.

💁 Possible Solution

When the selectedTabId changes, it should be passed as an argument to the onSelectionChange callback.

🔦 Context

No response

🖥️ Steps to Reproduce

https://codesandbox.io/p/sandbox/cmtrmq

Version

"react-aria-components": "1.3.3"

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

Ubuntu 20.04.6 LTS

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions