adobe / aem-spa-page-model-manager

Interface between Adobe Experience Manager and Single Page Application framework.
Apache License 2.0
35 stars 24 forks source link

[bug] using history.push() to navigate to a page result in empty page #80

Closed santiagozky closed 2 years ago

santiagozky commented 2 years ago

Describe the bug

We have a site with has too many pages reaching certain depth, so we have set our structureDepth to 1. This works fine for the most part and when clicking on links that takes to a page that is on a deeper level, it will get the new model.json file and render the page. But this does not seem to work as expected when using history.push('/path/to/a/page'). When we do that, the url is properly updated but no json is ever requested.

We follow a similar approach to the guide:

 ModelManager.initialize().then((pageModel) => {
    const history = createBrowserHistory();

    ...
    ...
   <Router history={history}>
        <App
          history={history}
    ...
    ...

Then a component will just do

import { useHistory, useLocation } from 'react-router-dom';
....
...
  const history = useHistory();
....
...
 history.push(`${url}/${id}.html`);

This works fine for pages within the first level of the page (which are in the initial model.json) but fails in deeper pages.

Package version using version 1.4.0

santiagozky commented 2 years ago

so I don't think this is a bug on here. I've replaced the logic with a simple in the app and it still doesnt work. I guess this will be some weird bug in our side.