Skip to content

Commit 7df6196

Browse files
committed
Add a comment for AI
1 parent cb42eb2 commit 7df6196

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/components/src/components/tabs/index.client.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ export const Tabs = ({
6767
for (const [index, el] of Object.entries(tabPanelsRef.current.children)) {
6868
if (el === tabPanel) {
6969
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+
7076
// Clear hash first, otherwise page isn't scrolled
7177
location.hash = '';
7278
// Execute on next tick after `selectedIndex` update

0 commit comments

Comments
 (0)