A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
web: use resizeobserver to wait for scroll container to resize
Abdullah Attac43c2936ac63
diff --git a/apps/web/src/components/editor/index.tsx b/apps/web/src/components/editor/index.tsxindex ef268c470..c00611563 100644--- a/apps/web/src/components/editor/index.tsx+++ b/apps/web/src/components/editor/index.tsx@@ -763,14 +763,23 @@ function restoreScrollPosition(session: EditorSession) {const scrollContainer = document.getElementById(`editorScroll_${session.id}`);const scrollPosition = Config.get(`${session.id}:scroll-position`, 0);if (scrollContainer) {- setTimeout(() => {- requestAnimationFrame(() => {- if (scrollContainer.scrollHeight < scrollPosition)- scrollContainer.style.minHeight = `${scrollPosition + 100}px`;- scrollContainer.scrollTop = scrollPosition;+ if (scrollContainer.scrollHeight < scrollPosition) {+ const observer = new ResizeObserver(() => {+ if (scrollContainer.scrollHeight >= scrollPosition) {+ observer.disconnect();+ requestAnimationFrame(+ () => (scrollContainer.scrollTop = scrollPosition)+ );+ clearTimeout(timeout);+ }});- scrollContainer.style.minHeight = "unset";- });+ observer.observe(scrollContainer);+ // eslint-disable-next-line no-var+ var timeout = setTimeout(() => {+ observer.disconnect();+ }, 30 * 1000);+ } else+ requestAnimationFrame(() => (scrollContainer.scrollTop = scrollPosition));}}