aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/DocumentView.tsx
diff options
context:
space:
mode:
authorGeireann Lindfield Roberts <60007097+geireann@users.noreply.github.com>2022-07-06 15:58:49 -0700
committerGeireann Lindfield Roberts <60007097+geireann@users.noreply.github.com>2022-07-06 15:58:49 -0700
commit03ef9aae8b91be25647dd2b9eb2dccc6ff435fcf (patch)
treebfdd705fe5e78b8159208c58016774658bcb022e /src/client/views/nodes/DocumentView.tsx
parentb476f81fbb7b7af32fdcc2fdd9fd1e2e2fc34014 (diff)
parent85e290ee7a666412570f2bae43a9b62d35b425f2 (diff)
Merge branch 'master' into geireann-eslint-prettier
Diffstat (limited to 'src/client/views/nodes/DocumentView.tsx')
-rw-r--r--src/client/views/nodes/DocumentView.tsx8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 360a9b242..7569b209d 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -470,10 +470,13 @@ export class DocumentViewInternal extends DocComponent<DocumentViewInternalProps
// after a timeout, the right _componentView should have been created, so call it to update its view spec values
setTimeout(() => this._componentView?.setViewSpec?.(anchor, LinkDocPreview.LinkInfo ? true : false));
const focusSpeed = this._componentView?.scrollFocus?.(anchor, options?.instant === false || !LinkDocPreview.LinkInfo); // bcz: smooth parameter should really be passed into focus() instead of inferred here
- const endFocus = focusSpeed === undefined ? options?.afterFocus : async (moved: boolean) => options?.afterFocus ? options?.afterFocus(true) : ViewAdjustment.doNothing;
+ const endFocus = focusSpeed === undefined ? options?.afterFocus : async (moved: boolean) => (options?.afterFocus?.(true) ?? ViewAdjustment.doNothing);
this.props.focus(options?.docTransform ? anchor : this.rootDoc, {
...options, afterFocus: (didFocus: boolean) =>
- new Promise<ViewAdjustment>(res => setTimeout(async () => res(endFocus ? await endFocus(didFocus) : ViewAdjustment.doNothing), focusSpeed ?? 0))
+ new Promise<ViewAdjustment>(res => setTimeout(async () => res(endFocus ?
+ await endFocus(didFocus||focusSpeed !== undefined) :
+ ViewAdjustment.doNothing), focusSpeed ?? 0)
+ )
});
}
@@ -696,6 +699,7 @@ export class DocumentViewInternal extends DocComponent<DocumentViewInternalProps
@action
onContextMenu = (e?: React.MouseEvent, pageX?: number, pageY?: number) => {
+ if (e?.nativeEvent.cancelBubble) return;
if (e && this.rootDoc._hideContextMenu && Doc.noviceMode) {
e.preventDefault();
e.stopPropagation();