Skip to content

Commit 4746eb4

Browse files
authored
fix: check if the content item zuid has a sibling that exists on the content nav (#2239)
1 parent 71730ed commit 4746eb4

File tree

1 file changed

+22
-2
lines changed
  • src/apps/content-editor/src/app/components/ContentNav

1 file changed

+22
-2
lines changed

src/apps/content-editor/src/app/components/ContentNav/index.tsx

+22-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ import {
3434
} from "../../../../../../shell/components/AppSidebar";
3535
import { NavTree, TreeItem } from "../../../../../../shell/components/NavTree";
3636
import { useGetCurrentUserRolesQuery } from "../../../../../../shell/services/accounts";
37-
import { useGetContentNavItemsQuery } from "../../../../../../shell/services/instance";
37+
import {
38+
useGetContentNavItemsQuery,
39+
useGetContentItemQuery,
40+
} from "../../../../../../shell/services/instance";
3841
import noSearchResults from "../../../../../../../public/images/noSearchResults.svg";
3942
import { CreateContentItemDialog } from "../../../../../../shell/components/CreateContentItemDialog";
4043
import {
@@ -99,6 +102,10 @@ export const ContentNav = () => {
99102
useGetCurrentUserRolesQuery();
100103
const { data: rawNavData, isError: navItemsError } =
101104
useGetContentNavItemsQuery(null, { refetchOnMountOrArgChange: true });
105+
const { data: contentItem } = useGetContentItemQuery(
106+
location.pathname.split("/")[3],
107+
{ skip: !location.pathname.split("/")[3] }
108+
);
102109

103110
const [closedNavItems, setClosedNavItems] = useLocalStorage(
104111
"zesty:navContentItems:closed",
@@ -393,11 +400,24 @@ export const ContentNav = () => {
393400
) {
394401
return pathWithoutContentZUID;
395402
}
403+
404+
/**
405+
* Checks if the current url has a sibling that exists on the content nav
406+
* Adds support to multi-lang content items
407+
*/
408+
if (!!contentItem?.siblings) {
409+
const siblingOnContentNav = Object.values(contentItem.siblings)?.find(
410+
(item) =>
411+
pathExists(mappedTree, `${pathWithoutContentZUID}/${item}`)
412+
);
413+
414+
return `${pathWithoutContentZUID}/${siblingOnContentNav}`;
415+
}
396416
}
397417

398418
return pathWithContentZUID;
399419
}
400-
}, [location, mappedTree, clippingsZUID]);
420+
}, [location, mappedTree, clippingsZUID, contentItem]);
401421

402422
useEffect(() => {
403423
if (currentUserRolesError) {

0 commit comments

Comments
 (0)