I just found out that AP.navigator.getLocation and the query param page.id might refer to the page visited before (not the current one) under the following conditions:
The current page is the home page of a space
The user used the breadcrumbs links to navigate to the space’s home page from another page in the space
Steps to reproduce:
Create a space with a home page and at least one child page
Ensure that you can use AP.navigator.getLocation on the space’s home page (alternative: have e.g. a webItem which consumes page.id)
Reload the space’s homepage and execute AP.navigator.getLocation - it returns the correct contentId
Navigate to a child page in the space
Navigate back to the space’s homepage using the breadcrumb links above the page’s title.
Execute AP.navigator.getLocation - its shows the contentId of the page visited before
I hadn’t noticed that exact problem, but had noticed an issue with custom overview (home) pages in spaces - it reports the default page, not the details of the app (it returns a different object for general pages). BTW page.id is deprecated.
The href field reported by getLocation reports the correct page, but the contentId is wrong (the previous page):
homepageId is the correct id, the contentId shown is the previous id.
In the interim, you could compare the href and reported contentId?
However, I have a webitem in the content tools menu and the query string reflects the correct info (including content.id/page.id).
You are right, the URL has the homepageId which I could use. However the content.id (thanks for pointing out the deprecation of page.id) is not correct for our webItem which points to a dialog.
For the time being this is my workaround for anybody dealing with the same:
const accountForHomePageBug = (location: Location) => {
// When on a home page, getCurrentLocation() often incorrectly returns the previously visited page
// Open ticket: https://ecosystem.atlassian.net/servicedesk/customer/portal/34/ECOHELP-43868
// The actual homepage ID is contained in the href, so we modify the payload.
try {
const contentId: number = location.context.contentId;
const href: string | undefined = location.href;
if (href?.includes('homepageId')) {
const parts = href.split('=');
const homepageId = parseInt(parts[parts.length - 1], 10);
if (contentId !== homepageId) {
location.context.contentId = homepageId;
}
}
} catch (error) {
console.error(
'An error occurred at getCurrentLocation():',
error,
);
}
return location;
};
Hi, everyone!
We know some of you have been waiting for years to have this fixed and we do apologize for that.
A partner raised a ticket about this issue a few days ago and we stumbled upon this old post with the same issue.
Please, be informed that https://jira.atlassian.com/browse/CONFCLOUD-79081 has been opened for this issue and hopefully it will be picked up for a fix soon.
Best!