Open kjellr opened 3 years ago
Some observations:
When using the "Primary/Secondary" colors as background colors the colors shown in the "editor" vs the "viewer" differ. This seems to stem from the same issue that incorrectly defines what the foreground color should be for elements with a "primary/secondary" background color while in dark mode.
Editor:
View:
And from what I can tell the 'View' instance is correct and the 'Editor' is not.
The cause seems to be that... the Customizer? is adding the background color as a style. Which is necessary for a "non primary/secondary/tertiary" color. However, the "dark mode" colors of what those "primary/secondary/tertiary" colors means something different than what the color swatches represent and shouldn't be enforced in that situation and rather rely on the .has-foreground-background-color[class] stylings.
So further research has determined that the cause is due to the DYNAMIC colors being defined in /spearhead/functions.php that define the 'editor-color-palette' colors. ONLY the 'light mode' colors are defined, thus even if the user's browser is in "dark mode" the "light mode" defined colors are shown in the editor. These are the colors that are applied to the element as a style which is causing the issue.
Because "foreground" is "Black" in light mode and "White" in dark mode, but only defined as "White" in the functions.php block the editor is always representing "foreground" as "black".
A possible fix would be to (somehow?) determine the light/dark mode of the user's browser when the editor page is rendered and supply the appropriate primary/secondary/tertiary colors based on that setting. I'm not sure that this is something (easily) possible, but that would give the editor the "correct" representation.
Another possible fix would be for the editor to ONLY apply the style to elements that are NOT styled using a pre-defined color (which appear to already be handled by adding the appropriate class). ( This has been opened to evaluate that particular fix.)
https://github.com/Automattic/themes/issues/2819 is the same issue
16005107-hc reported this today.
In light mode, the theme automatically adjusts the foreground text to pass contrast tests when one of the preset background colors is selected. This is broken when dark mode is active: