Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live preview in separate window does not work when iframe is closed #2

Open
Quadric opened this issue Oct 28, 2019 · 1 comment
Open

Comments

@Quadric
Copy link
Contributor

Quadric commented Oct 28, 2019

When i click "live preview" button it opens a new window with page preview. It refreshes in "real time" when i modify my page form so this works OK - but it stops working when i "hide" the iframe on right side of page form. If i show it again the separate full windows refreshes again.

// EDIT
OK i see that when i turn off iframe form does not make POST to live_preview thats why this separate full windows does not see changes when refreshes body.

Do you have any idea why it happens and how to fix it?

@Quadric Quadric changed the title Live preview in separate windows does not work when iframe is closed Live preview in separate window does not work when iframe is closed Oct 28, 2019
@KalobTaulien
Copy link
Owner

Hey @Quadric

I have the JavaScript not sending updates in the Wagtail admin when the live preview iframe is closed. My thinking was: if the iframe is closed the server shouldn't need to support requests it's not going to use. But I hadn't thought about the livepreview in a new window situation.

I'd like to stick to my original idea of not sending requests to the server if the iframe is closed, but adding livepreview window support is definitely important. I think there could be a very simple solution; it could be as easy as a file or simple query lookup. My idea is.. if someone clicked the Live Preview button it will open a new tab — it could also send a request to the server to create a file (or table row) to mark the page as "currently in live preview window". When that flag is active, the JavaScript could continue to send updates to the server even if the iframe is closed. The flag would need an active-until timestamp that's no more than 1 minute a head of right now, this way when the livepreview window is closed (and there isn't JavaScript support to detect when the window is closed) and the iframe is also closed, it doesn't keep sending requests to the server.

That's just my initial idea ¯_(ツ)_/¯ Im happy to discuss other ideas or improvements though! And I'm also happy to take PRSs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants