Closed srenault closed 3 years ago
Using https://developer.mozilla.org/en-US/docs/Web/API/Document/visibilityState
This property is supported by all browsers according to MDN. I tested locally and it works as expected: preview is refreshed when the browser page is visible (even if it has not the focus), and the refreshing is stopped when the page is hidden.
With these changes, a tab won't be updated unless it is fully visible. It means that the preview won't be updated when the changes occur but when the tab is visible.
For the dual screen it is a good thing. However, for a single screen with multiple tab, the preview will only be updated when the preview tab is selected, I don't know if this is acceptable.
I just tested the PR locally, it work as expected and I can confirm that if both tabs are on the same browser, the preview isn't updated if the tab is the not the active one.
fixes prismicio/issue-tracker-wroom#298