diff options
Diffstat (limited to 'src/client/util/DocumentManager.ts')
-rw-r--r-- | src/client/util/DocumentManager.ts | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts index ac3721436..5a6ce528f 100644 --- a/src/client/util/DocumentManager.ts +++ b/src/client/util/DocumentManager.ts @@ -272,7 +272,8 @@ export class DocumentManager { docContextPath.shift(); const childViewIterator = async (docView: DocumentView) => { const innerDoc = docContextPath.shift(); - return { focused: false, viewSpec: innerDoc, childDocView: innerDoc && !innerDoc.layout_unrendered ? (await docView.ComponentView?.getView?.(innerDoc, options)) ?? this.getDocumentView(innerDoc) : undefined }; + const viewSpec = innerDoc?.isGroup ? (docContextPath[0] ?? innerDoc) : innerDoc; + return { focused: false, viewSpec: viewSpec, childDocView: innerDoc && !innerDoc.layout_unrendered ? (await docView.ComponentView?.getView?.(innerDoc, options)) ?? this.getDocumentView(innerDoc) : undefined }; }; if (rootContextView) { @@ -294,6 +295,7 @@ export class DocumentManager { let contextView: DocumentView | undefined; // view containing context that contains target let focused = false; let docView = docViewIn; + let anchor = docView.Document; const options = optionsIn; const maxFocusLength = 100; // want to keep focusing until we get to target, but avoid an infinite loop for (let i = 0; i < maxFocusLength; i++) { @@ -306,13 +308,14 @@ export class DocumentManager { await prom; options.didMove = true; } - const nextFocus = docView._props.focus(docView.Document, options); // focus the view within its container + const nextFocus = docView._props.focus(anchor, options); // focus the view within its container focused = focused || nextFocus !== undefined; // keep track of whether focusing on a view needed to actually change anything // eslint-disable-next-line no-await-in-loop const { childDocView, viewSpec } = await iterator(docView); if (!childDocView) return { viewSpec: viewSpec ?? docView.Document, docView, contextView, focused }; contextView = !childDocView.Document.layout_unrendered ? childDocView : docView; docView = childDocView; + anchor = viewSpec ?? docView.Document; } return undefined; }; |