I am attempting to assist with what was spoken about in issue #48326 preview external window disappears. The goal is if the user chose to have a preview window open it should not disappear, nor should a new window open when advancing in the curriculum, but rather the same window should stay open and refresh with the data from the next challenge. additionally, as mentioned in the comments, I will close the window on leaving the challenges.
I am trying to implement the advise given in the issue but I think I am having difficulty in the saga.
on page load I get:
react-dom.development.js:237 Uncaught RangeError: Maximum call stack size exceeded.
and when I try to open the preview:
TypeError: Cannot read properties of undefined (reading 'createElement')
I guess it is because it was expecting a document but now it is recieving a window:
line 90 in previewPortal: this.props.storeportalWindow(this.externalWindow);
Please advise what is causing these two errors and how I can go about fixing them? Thank you.
Keep the same functionality as currently exists. Only, on advancing and moving backwards in the curriculum, if the portalWindow is open, keep it open and populate it with the new content. If going to another page non related to challenges (settings for example), close the portal window.
Please confirm that the advise given in the issue is correct :
That does sound like a decent plan of action. The main issue is ensuring the window closes when it should. Should the external window close if I navigate to /learn?
If you do this, be sure to do it in a separate PR.
My understanding is that line of code is necessary to prevent cases where the Camper navigates away from the current page, and the external window remains open. That is, before the main Window is disposed, ensure the external Window is closed.