fix: Scroll to document header on page load

This commit is contained in:
Tom Moor
2023-07-01 09:17:37 -04:00
parent aec190245b
commit f214db0ab7
2 changed files with 8 additions and 3 deletions

View File

@@ -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

View File

@@ -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}
/>