From f214db0ab70709ee94e6c20a4530f747839f0728 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sat, 1 Jul 2023 09:17:37 -0400 Subject: [PATCH] fix: Scroll to document header on page load --- app/editor/index.tsx | 10 +++++++--- app/scenes/Document/components/MultiplayerEditor.tsx | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/editor/index.tsx b/app/editor/index.tsx index c812e32ec..b810f4316 100644 --- a/app/editor/index.tsx +++ b/app/editor/index.tsx @@ -512,9 +512,13 @@ export class Editor extends React.PureComponent< try { this.mutationObserver?.disconnect(); - this.mutationObserver = observe(hash, (element) => { - element.scrollIntoView({ behavior: "smooth" }); - }); + this.mutationObserver = observe( + hash, + (element) => { + element.scrollIntoView({ behavior: "instant" }); + }, + this.elementRef.current || undefined + ); } catch (err) { // querySelector will throw an error if the hash begins with a number // or contains a period. This is protected against now by safeSlugify diff --git a/app/scenes/Document/components/MultiplayerEditor.tsx b/app/scenes/Document/components/MultiplayerEditor.tsx index e46c7e404..13993c127 100644 --- a/app/scenes/Document/components/MultiplayerEditor.tsx +++ b/app/scenes/Document/components/MultiplayerEditor.tsx @@ -284,6 +284,7 @@ function MultiplayerEditor({ onSynced, ...props }: Props, ref: any) { embedsDisabled={props.embedsDisabled} defaultValue={props.defaultValue} extensions={props.extensions} + scrollTo={props.scrollTo} readOnly ref={ref} />