aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/DocumentManager.ts
diff options
context:
space:
mode:
authorLionel Han <47760119+IGoByJoe@users.noreply.github.com>2020-09-12 13:32:35 -0700
committerLionel Han <47760119+IGoByJoe@users.noreply.github.com>2020-09-12 13:32:35 -0700
commit1508c81e2193f54da586f30da6f547bb1b89f976 (patch)
tree6d5629e0a8b245d7625d466915ae5309265414fb /src/client/util/DocumentManager.ts
parentd5e6a9c5d57b7c3315fb71f25eff8f883cc687ef (diff)
parent93b72ab7818e48592e9d42d092fa91b4ebedd49e (diff)
pull
Diffstat (limited to 'src/client/util/DocumentManager.ts')
-rw-r--r--src/client/util/DocumentManager.ts6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts
index f41c5e4cb..903760c58 100644
--- a/src/client/util/DocumentManager.ts
+++ b/src/client/util/DocumentManager.ts
@@ -10,6 +10,7 @@ import { Scripting } from './Scripting';
import { SelectionManager } from './SelectionManager';
import { DocumentType } from '../documents/DocumentTypes';
import { TraceMobx } from '../../fields/util';
+import { returnFalse } from '../../Utils';
export type CreateViewFunc = (doc: Doc, followLinkLocation: string, finished?: () => void) => void;
@@ -86,7 +87,8 @@ export class DocumentManager {
}
public getFirstDocumentView = (toFind: Doc, originatingDoc: Opt<Doc> = undefined): DocumentView | undefined => {
- return this.getDocumentViews(toFind)?.find(view => view.props.Document !== originatingDoc);
+ const views = this.getDocumentViews(toFind).filter(view => view.props.Document !== originatingDoc);
+ return views?.find(view => view.props.focus !== returnFalse) || (views.length ? views[0] : undefined);
}
public getDocumentViews(toFind: Doc): DocumentView[] {
const toReturn: DocumentView[] = [];
@@ -200,7 +202,7 @@ export class DocumentManager {
} else {
setTimeout(() => findView(delay + 250), 250);
}
- }
+ };
findView(0);
}
} else { // there's no context view so we need to create one first and try again