fix(ui): prevent infinite render loop in Tabs with routed tabs
When navigating to a URL that doesn't match any tab href, the Tabs
component would pass `selectedKey={null}` to React Aria's Tabs,
which triggers an infinite render loop.
This fix uses an empty string instead of null to indicate no
selection, which React Aria handles correctly.
Signed-off-by: Johan Persson <johanopersson@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/ui': patch
|
||||
---
|
||||
|
||||
Fixed an infinite render loop in Tabs when navigating to a URL that doesn't match any tab href.
|
||||
@@ -135,9 +135,10 @@ export const Tabs = (props: TabsProps) => {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Has routed tabs but none are active - controlled mode with no selection
|
||||
// Has routed tabs but none are active - use empty string for no selection
|
||||
// (React Aria has a bug with null that causes infinite loops)
|
||||
if (activeTabs.size === 0) {
|
||||
return null;
|
||||
return '';
|
||||
}
|
||||
|
||||
let selectedId: string | null = null;
|
||||
|
||||
Reference in New Issue
Block a user