chrome.browserAction setBadgeForegroundColor -- New Contrast Color Change

95 views
Skip to first unread message

Mike-O

unread,
Jul 10, 2022, 5:55:11 PM7/10/22
to Chromium Extensions
So, there's no chrome.browserAction.setBadgeForegroundColor, but there's a setBadgeBackgroundColor. This was fine and my text showed up with contrast on my background color and was white. But then, somewhere along the different browser versions, the foreground color became black and I don't know why. Example:


Now, I will say that I did experiment with a dark theme in my browser briefly, but then turned that off and went back to the light theme. So, I don't know if that's the reason, or if there was a code change in Google Chrome where they decided to change how they pick the foreground color for contrast based on the background color.

Can anyone who's seen the internal code changes for chrome.browserAction explain if it was a browser change? Or, is it something I've done to my browser settings?

Mike-O

unread,
Jul 10, 2022, 7:45:43 PM7/10/22
to Chromium Extensions, Mike-O
Note that it is interesting that FF supports setBadgeTextColor(). For now, Chrome does not.

hrg...@gmail.com

unread,
Jul 10, 2022, 8:10:43 PM7/10/22
to Chromium Extensions, Mike-O
They changed that in Chrome 103.
Up until Chrome 102, the text would've been white.

Jackie Han

unread,
Jul 11, 2022, 12:18:16 AM7/11/22
to hrg...@gmail.com, Chromium Extensions, Mike-O
I found Chrome selects white or black text color on the badge automatically recently. For example, 
  • if your icon is blue/green/yellow, then the badge background color is the same color as the icon, and the text color is black.
  • if your icon is red/green, then the badge background color is the same color as the icon, and the text color is white.
In some cases above, the text color is hard to read. So I think it solves some problems in some cases, but it leads to other problems in other cases. Maybe the code quality of Chrome team has declined.


--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/68117e08-d203-4913-a5bb-efecc880b0den%40chromium.org.

Jackie Han

unread,
Jul 11, 2022, 12:20:29 AM7/11/22
to hrg...@gmail.com, Chromium Extensions, Mike-O
fix a typo: "if your icon is red/green" -> "if your icon is red/gray"

Jackie Han

unread,
Jul 11, 2022, 12:23:51 AM7/11/22
to hrg...@gmail.com, Chromium Extensions, Mike-O
In the past, if the background color was blue, then the text color was white.
But now, if the background color is blue, then the text color is black.

Jackie Han

unread,
Jul 11, 2022, 12:44:21 AM7/11/22
to hrg...@gmail.com, Chromium Extensions, Mike-O
I searched a bit, and found someone reported a bug:

Mike-O

unread,
Jul 11, 2022, 12:52:16 AM7/11/22
to Chromium Extensions, Jackie Han, Chromium Extensions, Mike-O, hrg...@gmail.com
Thank you for the research on this, guys. I edited the bug report and mentioned how FF is handling this. Perhaps a future Chrome will support setBadgeTextColor() as an override to the auto-assignment. They might also do a better job of showing contrast on the automatic foreground color, perhaps, whether it picks white or black.

Jackie Han

unread,
Nov 15, 2022, 3:02:03 PM11/15/22
to hrg...@gmail.com, Chromium Extensions, Mike-O
Now, the bug is fixed. There is a new api: action.set/getBadgeTextColor() starting from M110. You can test it on Chrome Canary now.
Reply all
Reply to author
Forward
0 new messages