fix(scroll): snap to click-time scrollTop before smooth scroll

Capture mainApp.scrollTop synchronously when addStackedNote runs and
snap the scroll back to that value before scrollIntoView fires, so
the smooth scroll begins from where the user actually tapped rather
than from a position drifted by momentum or async work.
This commit is contained in:
Julien Calixte
2026-05-04 19:57:00 +02:00
parent 08e01d8484
commit a526a9f6af
2 changed files with 13 additions and 1 deletions

View File

@@ -114,6 +114,10 @@ export const useRouteQueryStackedNotes = () => {
selector?: string,
hash?: string
) => {
const mainAppEl = document.getElementById("main-app")
;(window as unknown as { __scrollAtClick?: number }).__scrollAtClick =
mainAppEl?.scrollTop ?? 0
if (stackedNotes.value.includes(sha)) {
scrollToFocusedNote({
noteId: selector ?? sha,