aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/DocumentManager.ts
diff options
context:
space:
mode:
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..9bf10d167 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) || (view.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