Closed Bug 1888866 Opened 1 year ago Closed 1 year ago

Addons options_ui browser_style false doesn't properly handle dark mode on macOS

Categories

(Toolkit :: Add-ons Manager, defect, P3)

Firefox 124
defect

Tracking

()

VERIFIED FIXED
127 Branch
Tracking Status
firefox124 --- wontfix
firefox125 --- wontfix
firefox126 --- wontfix
firefox127 --- verified

People

(Reporter: firefox, Assigned: robwu)

References

Details

(Keywords: dev-doc-complete, Whiteboard: [addons-jira])

Attachments

(6 files)

Attached file manifest.json

Steps to reproduce:

  1. Switch to dark mode on macOS
  2. Load the attached add-on Dark Mode Bug in about:debugging#/runtime/this-firefox
  3. Open about:addons
  4. Selec Dark Mode Bug Preferences

Actual results:

The Preferences background is white rather than black, but the text is white and thus unreadable.

Expected results:

The Preferences background should be dark.

Attached file options.html

The Bugbug bot thinks this bug should belong to the 'Toolkit::Add-ons Manager' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Add-ons Manager
Product: Firefox → Toolkit
Attached image browser_style false.png
Attached image browser_style true.png

I was told in https://bugzilla.mozilla.org/show_bug.cgi?id=1880107 to use browser_style false to fix a bug with the appearance of <hr> elements, but dark mode only works correctly with browser_style true.

Hello,

I reproduced the issue on the latest Nightly (126.0a1/20240402213900), Beta (125.0b7/20240401091600) and Release (124.0.1/20240321230221) under Windows 10 and macOS 11.3.1 using the attached extension.

With dark mode enabled, the options page of the extension has a white background and white text, making the text unreadable.

Status: UNCONFIRMED → NEW
Ever confirmed: true

Rob is going to take a closer look.

Flags: needinfo?(rob)

When browser_style is true, the color is always #222426 and the background always transparent, which is effectively blank regardless of the dark/light theme selected through color-scheme. Note that other HTML (including the input) are rendered for theme, so ideally the outcome should be for the background to be dark and the color to be light.

When browser_style is false (which is the new default, and cannot be reverted in MV3), the color is CanvasText (black in light mode, blank in dark mode). The background is still transparent (the default), which is somehow blank, independently of the dark/light scheme.

The bug here is thus that the background is unconditionally blank, independently of the preferred color scheme. I'll submit a patch to fix the issue when browser_style:false is used.

The question is what to do when browser_style:true is used - continue using the fixed color, or drop the default color. In the interest of minimizing visual regressions, balanced against the intent when color-scheme: light dark is used, I think that we could put the color: #222426 declaration in a media query (prefers-color-scheme) to limit that color to when the light theme is selected, so that if an extension uses color-scheme: dark light, that the expected result happens without additional CSS hacks. An alternative is to fix the root's color to white unconditionally (instead of transparent) to have the result from before. While this would keep the behavior unchanged, it invalidates the expectation that developers have of color-scheme: dark.

Assignee: nobody → rob
Flags: needinfo?(rob)
Whiteboard: [addons-jira]
Severity: -- → S4
Priority: -- → P3

This patch changes the behavior for extensions with an embedded
options_ui page (open_in_tab not false), that have specified the
"dark" value in the "color-scheme" meta tag or CSS property, AND
with the user having indicated the preference for dark theme support.
There are no changes when any of these conditions have not been met.

The "color-scheme" CSS property is the standard way for extensions (web
pages in general) to opt in to automatic dark theme support, e.g. by
changing the foreground color to white. Prior this patch, the
background was unconditionally white, which resulted in unreadable text
when the dark theme is enabled. This patch changes the default
background color to "Canvas", which is a special keyword that is dark
theme-aware (almost black - rgb(28, 27, 34) by default).

When browser_style:true is used (which is the default in MV2),
extension.css is activated, which unconditionally specifies a black
foreground color. To avoid a poor contrast with the new theme-dependent
background color, the color is now white when the dark theme is enabled.

This patch includes comprehensive test coverage, but the only tests
whose behavior changed by this patch are:

  • options_ui_dark (background changed)
  • options_ui_browser_style_true_dark (color, background changed)
See Also: → 1881055

dev-doc-needed (see comment 9 for details):

Here is an example of <meta name="color-scheme" content="dark light"> in action: https://github.com/Rob--W/fosdem-2024-ext/blob/a98c24af4571b1d8a1b9b9d0689e70fec9bad0ca/code-samples/content_scripts.mv3%2Boptions_ui/options.html#L7
note that background: Canvas was specified there, to work around this bug. With this bug fixed, that work-around is no longer needed, and adding a meta tag is all that's needed to have automatic dark theme support working out of the box.

Keywords: dev-doc-needed
Pushed by rob@robwu.nl: https://hg.mozilla.org/integration/autoland/rev/3504712be7dd Improve dark theme support in options_ui r=willdurand,desktop-theme-reviewers,emilio
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 127 Branch

The patch landed in nightly and beta is affected.
:robwu, is this bug important enough to require an uplift?

  • If yes, please nominate the patch for beta approval.
  • If no, please set status-firefox126 to wontfix.

For more information, please visit BugBot documentation.

Flags: needinfo?(rob)

Verified as Fixed. Tested on the latest Nightly (127.0a1/20240418214121) under Windows 10 x64 and Ubuntu 22.04 LTS.

The preferences page background is now dark, and text is visible. See the attached screenshot.

Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: