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

detachable views have white screen before "First Contentful Paint (FCP)" #14521

Open
nimo23 opened this issue Nov 25, 2024 · 3 comments
Open

Comments

@nimo23
Copy link

nimo23 commented Nov 25, 2024

Feature Description:

When we detach a view (e.g. the "Source Editor" view), then a white screen is shown for a very short moment (about 1-2 seconds) ("First Contentful Paint (FCP)"), which is also a bit annoying when dark mode is active. It would be nice if the detached view had at least the same background color as the original view when loading the content (e.g. by using "React.useLayoutEffect" while rendering the detached view or some other possible optimizations).

@JonasHelming
Copy link
Contributor

@tsmaeder @sdirix

@tsmaeder
Copy link
Contributor

We are using the javascript window.open() call to create secondary windows. As such, we have little direct control over the window lifecyle, in particular we can't wait to show the window until the content is ready like when creating windows from electron. Determining the background color in the window itself is a non-starter, since we need to load a lot of javascript to find out what that is. We'd have to communicate the background color via some side channel (maybe a parameter on the window url?)

@nimo23
Copy link
Author

nimo23 commented Nov 25, 2024

maybe a parameter on the window url

That sounds good. For example:

// Set the query parameter to the URL 
// using the current background color of the window to be detached
..

// Get the query parameter from the URL
const urlParams = new URLSearchParams(window.location.search);
const bgColor = urlParams.get('bgColor');

// Open a new window
const newWindow = window.open('', '_blank');

// Set the background color of the new window
if (bgColor) {
  newWindow.document.body.style.backgroundColor = bgColor;
}

Another approach would be to preload the content before inserting it into the detached window, but I think the URL approach is better.

One thing to consider is that if you change the theme (e.g. from dark to light) while detached windows are open, the detached windows should also inherit those styles (e.g. background color).

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

3 participants