Skip to content

Commit 7e8833a

Browse files
fix resource tab scroll
1 parent b95c255 commit 7e8833a

File tree

1 file changed

+6
-2
lines changed
  • apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-tabs

1 file changed

+6
-2
lines changed

apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-tabs/resource-tabs.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,12 @@ export function ResourceTabs({
185185
if (!node || !activeId) return
186186
const tab = node.querySelector<HTMLElement>(`[data-resource-tab-id="${CSS.escape(activeId)}"]`)
187187
if (!tab) return
188-
const tabLeft = tab.offsetLeft
189-
const tabRight = tabLeft + tab.offsetWidth
188+
// Use bounding rects because the tab's offsetParent is a `position: relative`
189+
// wrapper, so `offsetLeft` is relative to that wrapper rather than `node`.
190+
const tabRect = tab.getBoundingClientRect()
191+
const nodeRect = node.getBoundingClientRect()
192+
const tabLeft = tabRect.left - nodeRect.left + node.scrollLeft
193+
const tabRight = tabLeft + tabRect.width
190194
const viewLeft = node.scrollLeft
191195
const viewRight = viewLeft + node.clientWidth
192196
if (tabLeft < viewLeft) {

0 commit comments

Comments
 (0)