From cc266eac7c515563a2b0a6d1c6712fe8b03c1be6 Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Mon, 4 May 2026 18:29:05 +0200 Subject: [PATCH] refactor(scroll): delegate note scroll to scrollIntoView Native scrollIntoView reads the element position at scroll time and picks the right scrollable ancestor itself, sidestepping iOS Safari quirks with scrollTo on overflow containers and visual-viewport shifts. --- src/hooks/useOverlay.hook.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/hooks/useOverlay.hook.ts b/src/hooks/useOverlay.hook.ts index 1abba02..621e5b1 100644 --- a/src/hooks/useOverlay.hook.ts +++ b/src/hooks/useOverlay.hook.ts @@ -41,15 +41,8 @@ export const useOverlay = (listen = true) => { } const scrollToElement = (element: HTMLElement) => { - const mainApp = document.getElementById("main-app") - if (!mainApp) return - requestAnimationFrame(() => { - const top = - element.getBoundingClientRect().top - - mainApp.getBoundingClientRect().top + - mainApp.scrollTop - mainApp.scrollTo({ top, behavior: "smooth" }) + element.scrollIntoView({ behavior: "smooth", block: "start" }) }) }