We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cb42eb2 commit 7df6196Copy full SHA for 7df6196
packages/components/src/components/tabs/index.client.tsx
@@ -67,6 +67,12 @@ export const Tabs = ({
67
for (const [index, el] of Object.entries(tabPanelsRef.current.children)) {
68
if (el === tabPanel) {
69
setSelectedIndex(Number(index));
70
+ // Note for posterity:
71
+ // This is not an infinite loop. Clearing and restoring the hash is necessary
72
+ // for the browser to scroll to the element. The intermediate empty hash triggers
73
+ // a hashchange event, but React bails out when restoring the same hash value,
74
+ // preventing an infinite loop.
75
+
76
// Clear hash first, otherwise page isn't scrolled
77
location.hash = '';
78
// Execute on next tick after `selectedIndex` update
0 commit comments