Skip to content

Tabs infinitely rerenders when selectedKey is null #9584

@abeljohn

Description

@abeljohn

Provide a general summary of the issue here

When setting the selectedKey on RAC Tabs to null, Error: Maximum update depth exceeded. is thrown repeatedly and the browser freezes up due to the infinite rerender.

🤔 Expected Behavior?

Tabs should render with no Tab selected when selectedKey is null, since null is allowed by the SingleSelection types

😯 Current Behavior

Tabs infinitely rerenders when selectedKey is null and throws errors repeatedly.

💁 Possible Solution

Seems to be a regression in RAC 1.14. I bisected RAC nightlies and found it was introduced between 3.0.0-nightly-0836d3a4e-251017 and 3.0.0-nightly-02433d1f1-251018, so most likely #9041 and the resulting extra rerender. However, this seems like a logic issue in useTabListState so I think it can be fixed there

A workaround is to set the selectedKey to a nonexistent Key instead of null in order to control the "no tab selected" state

🔦 Context

There is a case where Tabs state is controlled and initially nothing is selected, so it seems reasonable to pass null as the selectedKey

🖥️ Steps to Reproduce

https://codesandbox.io/p/sandbox/peaceful-jackson-lxxwyr (open the browser console)

Version

RAC 1.14.0

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

macOS 15

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions