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
feat: add transparent
webpreference to webview
#40301
Conversation
💖 Thanks for opening this pull request! 💖 We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix. Examples of commit messages with semantic prefixes:
Things that will help get your PR across the finish line:
We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can. |
opaque
attribute to webview
I hadn't realized defaulting
|
Sounds good! I initially thought having to enable transparency seemed more intuitive since iframes are opaque by default, but I'm not sure if that warrants breaking the current default behaviour. Thanks for looking into this for me and I look forward to hearing back. |
@BrandonXLF the @electron/wg-api discussed the API and thought of adding <!-- Disable transparency -->
<webview webpreferences="transparent=no"></webview>
<!-- Enable transparency -->
<webview webpreferences="transparent=yes"></webview>
<webview></webview> This would avoid the naming awkwardness and any breaking changes. |
opaque
attribute to webviewtransparent
webpreference to webview
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API LGTM
docs/api/webview-tag.md
Outdated
The full list of supported preference strings can be found in [BrowserWindow](browser-window.md#new-browserwindowoptions) | ||
in addition to `transparent`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few suggestions here:
- Use a list similar to the linked docs for web preferences.
- Link to native theme source. It seems like that's what's being referred to when you mentioned color scheme.
The full list of supported preference strings can be found in [BrowserWindow](browser-window.md#new-browserwindowoptions) | |
in addition to `transparent`. | |
The full list of supported preference strings can be found in [BrowserWindow](browser-window.md#new-browserwindowoptions). In addition, webview supports the following preferences: | |
- `transparent` boolean (optional) - Whether to enable background transparency in the guest page. Default is `true`. **Note:** Text and background colors are derived based on the [native theme source](native-theme.md#nativethemethemesource) by default. When transparency is enabled, the text color may still change accordingly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched to the suggested list format and added a link to https://developer.mozilla.org/en-US/docs/Web/CSS/color-scheme.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API LGTM
@zcbenz @samuelmaddock It looks like one of the Mac OS tests timed out, would you be able to rerun them? |
@BrandonXLF Sorry for the delay, #35658 has been merged recently and this PR has a minor conflict with it, can you rebase this branch on latest main? After that I'll merge this PR. |
Retains current webview behaviour by default.
I'm merging this PR since it has implemented the API requested by API working group. |
Release Notes Persisted
|
Add a
transparent
webpreference that when disabled makes webviews have an opaque background that follows the guest page's color scheme.Fixes #40207
Checklist
npm test
passesRelease Notes
Notes: Added a
transparent
webpreference to webviews