From 808129bafb4c4166bef1ca3128252be45e4a2b05 Mon Sep 17 00:00:00 2001 From: themechbro Date: Mon, 30 Mar 2026 15:49:08 +0530 Subject: [PATCH] fix(react-aria): handle position fixed in getTotalOffsetTop to prevent scroll jump (fixes #35921) --- .../library/src/activedescendant/scrollIntoView.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/react-components/react-aria/library/src/activedescendant/scrollIntoView.ts b/packages/react-components/react-aria/library/src/activedescendant/scrollIntoView.ts index e6a5ae1b6f22e4..6d9f83b10d4deb 100644 --- a/packages/react-components/react-aria/library/src/activedescendant/scrollIntoView.ts +++ b/packages/react-components/react-aria/library/src/activedescendant/scrollIntoView.ts @@ -49,6 +49,14 @@ const getTotalOffsetTop = (element: HTMLElement, scrollParent: HTMLElement): num return scrollParent.offsetTop * -1; } + // Handle position: fixed elements where offsetTop is unreliable + const win = element.ownerDocument?.defaultView; + const isFixed = win && win.getComputedStyle(element).position === 'fixed'; + + if (isFixed) { + return element.getBoundingClientRect().top + getTotalOffsetTop(element.offsetParent as HTMLElement, scrollParent); + } + return element.offsetTop + getTotalOffsetTop(element.offsetParent as HTMLElement, scrollParent); };