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

[Bug]: setWindowOpenHandler results in incorrect dark mode background color for text/plain content #36538

Closed
3 tasks done
jeremyspiegel opened this issue Dec 1, 2022 · 3 comments · Fixed by #36914
Closed
3 tasks done
Assignees
Labels
19-x-y 20-x-y 21-x-y 22-x-y 23-x-y bug 🪲 component/BrowserWindow has-repro-gist Issue can be reproduced with code at https://gist.github.com/ status/confirmed A maintainer reproduced the bug or agreed with the feature

Comments

@jeremyspiegel
Copy link
Contributor

jeremyspiegel commented Dec 1, 2022

Preflight Checklist

Electron Version

Electron 21.3.1, 22.0.0, and the latest 24.0.0-nightly.20221201

What operating system are you using?

macOS 13 and Windows 11

What arch are you using?

arm64 (including Apple Silicon)

Last Known Working Electron version

n/a

Expected Behavior

When the system is in dark mode, and a popup is opened via window.open to a URL returning content of type text/plain, the resulting popup window should have a black background with white text. This happens correctly unless mainWindow.webContents.setWindowOpenHandler is called.

See https://www.loom.com/share/4af414156762410e994b5e2a56d997c7 for the correct behavior when mainWindow.webContents.setWindowOpenHandler is commented out.

image

Actual Behavior

With the call to mainWindow.webContents.setWindowOpenHandler uncommented, the popup window incorrectly has white text with a white background. See https://www.loom.com/share/15aadf785f3740c5b8f07239ea1e46ed for the actual behavior.

image

Testcase Gist URL

https://gist.github.com/36925a2377d0b8c7c67abd9816c2f411

@jeremyspiegel
Copy link
Contributor Author

I think this is related to #28054. cc @MarshallOfSound

@dsanders11
Copy link
Member

Text in the opened window first turned white starting in 19.0.0-nightly.20220325.

@dsanders11 dsanders11 added 19-x-y 20-x-y 21-x-y 22-x-y 23-x-y status/confirmed A maintainer reproduced the bug or agreed with the feature has-repro-gist Issue can be reproduced with code at https://gist.github.com/ labels Jan 14, 2023
@dsanders11
Copy link
Member

I'm investigating root cause, but in the mean time, this is a workaround which causes the behavior to be the same whether setWindowOpenHandler is set or not:

mainWindow.webContents.setWindowOpenHandler(() => ({action: 'allow', overrideBrowserWindowOptions: { backgroundColor: '000000' }}))

The backgroundColor value doesn't matter, as it will be immediately replaced by the expected background color for dark mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
19-x-y 20-x-y 21-x-y 22-x-y 23-x-y bug 🪲 component/BrowserWindow has-repro-gist Issue can be reproduced with code at https://gist.github.com/ status/confirmed A maintainer reproduced the bug or agreed with the feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants