-
Notifications
You must be signed in to change notification settings - Fork 38
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
Color Module cannot save colors if uppercase hex codes used in theme's color.inc #6057
Comments
@ericfoy If you are able to provide specific steps to reproduce this problem, that would be helpful. |
Through the process of debugging my issue, I put a comment header in my "colors.css" file (the only file I set to be processed by the color module) to help me discover what substitutions were being made by the color module code. Note that I simply repeated the colors, omitting the # in front of one column. My thinking was:
So here are the resulting outputs of two versions; one with upper case hex values, the other with lower case. These are snapshots of the system-generated colors.css file found in the files/color/[my_theme] folder:
And here is the failure case:
Note that these are both output files. In the original unprocessed css file both columns are the same (except for the missing # in the first column. This allows me to see what each color was substituted with after processing, making it easy for me to fill out the colors of my stock schemes in color.inc |
Thanks @ericfoy 🙏🏼 ...I could spend some time to whip up a minimal test custom theme that implements color support, and then start working with that, but it would greatly help if you reduced the theme you are currently working with down to basics and uploaded a copy of that here. That would save me (or anyone else willing to work on a fix for this bug) some time/trouble. So I will try to start working on it, but would be awesome if you beat me to it and uploaded a sample theme that I can test/troubleshoot with. |
I think it's easier than that...
Look now at the replacement colors.css file found in the files/color/modoc--- folder. In there, you can see the replacement values as described in my earlier comment. |
While perusing color.module, I ran across line 467 Seems like it should look more like this: When I get some time, I'll play around a bit with this... |
The used pattern is case-insensitive. That is what the i at the end the pattern means ( The complete list of modifiers is given on Pattern Modifiers. |
Ohhhhhh Oh well. |
Turns out, I had errantly diagnosed the actual problem. The color module handles upper case hex values in the CSS just fine. The problem arises when upper case is used in the color.inc file by the theme designer. I could give excuses for why I mis-reported this issue, but I won't waste anybody's time. Sorry about that. In any event, I find that the following change seems (upon initial impression--more testing and verification is in order) to fix the problem... I'll do a little more testing and verification, and then submit a PR... |
Here is a lengthy analysis: Test Case 1: Everything lower case. Normal setupIn the color.inc file, we have the following excerpt, which defines the default color scheme (Note that all color hex values are in lower case only):
The following excerpt is in the header of 'colors.css' (the only css file configured for the color module to scan and process.
After selecting a different color scheme via the UI at admin/appearance/settings/modoc, files/color/modoc-fce85949
Note here that all of the original color codes remain in the first column, and that their replacement Test Case 2: Introduction of upper case hex values into the CSS file:Original file:
Output file:
Here we see that the color module has had no problems dealing with upper case or mixed-case hex color values, and that all the appropriate substitutions have been made. Test case 3: Introduction of upper case hex values into color.incexcerpt from color.inc
Note the existence of upper case letters in the array definition above. Now, we have Test sub-case 3a, in which the CSS file duplicates the upper case propensities of the color.inc array definition... Original file:
Output file:
Notice all the zeros. This is a failure case. Likewise, for Test case 3b, in which the CSS file contains only lower case hex values, we get the same failure: Original file:
Output file:
So we conclude that the problem lies in the fact that the color.inc file (the array definition) contains upper case hex values. I will introduce Test case 4 in the next comment: the case where the predefined schemes (other than the default) contain upper case... This will determine whether further modification of the code is required... |
Test case 4: Predefined schemes (other than the default) contain upper case.It appears that this case causes no problems whether before or after my patch has been applied. Although I could spend untold amounts of time figuring out why this is the case, I think I'd rather simply be satisfied that everything seems to work. —Eric |
@ericfoy thank you for providing a PR and detailed explanation for this 🙏🏼 @backdrop/core-committers can one of you please approve the PR so that the tests can run? Thanks. |
...I've left some comments in that PR. |
New PR... |
…sed in theme's color.inc. By @ericfoy, @stpaultim, @kiamlaluno, and @klonos.
…sed in theme's color.inc. By @ericfoy, @stpaultim, @kiamlaluno, and @klonos.
Thanks @ericfoy! I tested this manually and confirmed it fixes the saving (and loading) of color values if a theme uses uppercase letters in it's Merged into 1.x and 1.25.x, thanks! backdrop/backdrop@2efff2a by @ericfoy, @stpaultim, @kiamlaluno, and @klonos. |
Creating a separate issue for this comment raised here: #1905
Description of the bug
Color Module is intolerant of upper case hex values.
I used uppercase hex values in my css file, only to learn (after three hours of head-scratching and hair-pulling) that the Color Module is intolerant of upper case letters. It reads #45C690 as #000000, and proceeds from there. So you basically get kind of a dark mode thing going for all your color configurations. Once I replaced my biggie letters with smallies, everything worked great.
The issue shows up when you include upper case hex colors in your css file, and the Backdrop Color Module tries to process it (doing color substitutions). It croaks on upper case text.
This issue also discussed here: https://forum.backdropcms.org/forum/color-module-cant-handle-uppercase-hex
The text was updated successfully, but these errors were encountered: