Skip to content

Commit cab81e6

Browse files
authored
FIX: Different split opening behavior after first navigation (#909)
1 parent 4052b54 commit cab81e6

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

packages/frontend/src/page/document_page.tsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,28 @@ export default function DocumentPage() {
7474

7575
const [secondaryLiveDoc, { refetch: refetchSecondaryDoc }] = createResource(
7676
() => {
77-
if (!params.subkind || !params.subref) {
78-
return;
77+
// Always return an object so fetcher runs and can clear the resource
78+
return {
79+
kind: params.subkind || null,
80+
ref: params.subref || null,
81+
primaryRef: params.ref,
82+
};
83+
},
84+
async (source) => {
85+
// Return undefined to clear resource when there's no secondary in URL
86+
if (!source.kind || !source.ref) {
87+
return undefined;
7988
}
8089

81-
// Prevent the fetcher from running right before the redirect runs for matching primary and secondary refs
82-
if (params.subref === params.ref) {
83-
return;
90+
// Prevent fetching right before redirect for matching refs (maximizing)
91+
if (source.ref === source.primaryRef) {
92+
return undefined;
8493
}
8594

86-
return [params.subkind, params.subref] as const;
95+
return getLiveDocument(source.ref, api, models, source.kind as DocumentType);
8796
},
88-
([refKind, refId]) => getLiveDocument(refId, api, models, refKind as DocumentType),
8997
);
98+
9099
const closeSidePanel = () => {
91100
navigate(`/${params.kind}/${params.ref}`);
92101
};

0 commit comments

Comments
 (0)