Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Nagendra7509 opened this issue Dec 17, 2024 · 1 comment · May be fixed by #7529
Open

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

Nagendra7509 opened this issue Dec 17, 2024 · 1 comment · May be fixed by #7529
Labels
bug Something isn't working

Comments

@Nagendra7509
Copy link

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

@snowystinger snowystinger linked a pull request Dec 17, 2024 that will close this issue
5 tasks
@snowystinger
Copy link
Member

I see it, looks like a bug. Thanks for the reproduction.

@snowystinger snowystinger added the bug Something isn't working label Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants