Bug 220367

Summary: WKWebView in a fullscreen Quick Look preview fail the CSS media query prefers-color-scheme for root var
Product: WebKit Reporter: sbarex
Component: WebKit2Assignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Normal CC: koivisto, thorton, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 14   
Hardware: Mac (Intel)   
OS: macOS 11   

sbarex
Reported 2021-01-06 09:31:50 PST
I have a WKWebView inside a Quick Look preview appex on Big Sur. I customize the html with a CSS that define the colors with :root vars. A media query for dark color scheme is used to override the var defined for the light appearance: <style type="text/css"> :root { --backgroundColor: #eeeeee; --textColor: #333333; } .myclass { color: blue; } @media (prefers-color-scheme: dark) { :root { /* BUG: in light mode and fullscreen preview these vars are used overriding the light theme. */ --backgroundColor: #333333; --textColor: #eeeeee; --linkColor: #3366ff; } .myclass { /* In in light mode and fullscreen preview these class is not overrided by dark scheme. */ color: yellow; } } body { color: var(--textColor); background-color: var(--backgroundColor); } </style> The style works well on the Quick Look preview. But if macOS is in light mode and I maximize the QL Preview to fullscreen, the webview uses the vars defined for the dark appearance. This bug occurs only for properties defined with vars. The other css classes is not affected. I have created a demo code here: https://github.com/sbarex/QLTest
Attachments
Radar WebKit Bug Importer
Comment 1 2021-01-13 09:32:14 PST
Note You need to log in before you can comment on or make changes to this bug.