wbrowar / craft-admin-bar

Front-end shortcuts for clients logged into Craft CMS.
MIT License
32 stars 9 forks source link

Custom CSS in CMS Settings Page has entities (quotes specifically) escaped on save #32

Closed mscherr-fastspot closed 10 months ago

mscherr-fastspot commented 10 months ago

Craft CMS Version - 4.5.11.1 Plugin Version - 3.2.0

The example used for changing the font stack is:

--adminbar-font-stack: 'BlinkMacSystemFont', -apple-system, 'Trebuchet MS', 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Tahoma, sans-serif;

... but when adding that exact example into the "Colors > Custom CSS" text box:

:root {
--adminbar-font-stack: 'BlinkMacSystemFont', -apple-system, 'Trebuchet MS', 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Tahoma, sans-serif;
}

... on the front end the custom property is invalid, and the preview shows &#039 as the first few characters, leading me to believe quotes are being escaped.

CleanShot 2023-11-29 at 14 23 30

Example of settings page:

CleanShot 2023-11-29 at 14 19 41

wbrowar commented 10 months ago

Hi, @mscherr-fastspot, how are you rendering Admin Bar on your template (using the adminbar Twig tag or using getAdminBarAssets along with it)? Can you please share the Twig code you're using?

wbrowar commented 10 months ago

Also, I just tried this out in the beta version of Admin Bar 4 and it doesn't seem to be an issue anymore. If it turns out there is a bug in the 3.2.x version I'll go back and fix it, but FYI it doesn't seem to be an issue in the newer version.

Screenshot 2023-11-29 at 6 50 55 PM Screenshot 2023-11-29 at 6 51 47 PM
mscherr-fastspot commented 10 months ago

@wbrowar I am using the Twig tag:

{% if entry is defined %}
    {{ adminbar({
        entry: entry
    }) }}
{% endif %}
wbrowar commented 10 months ago

Hmm well I think there are a couple of ways we could solve this. One route could be to change the single quotes to double quotes. Or we could update the font stack to something that won't run into this issue. Because this is stored in settings, I wonder if it's a database storage issue.. In that case then I could see this still being an issue in the 4.0 version.

Would you mind trying out the beta version of 4.0? You can do this by updating Admin Bar via composer:

{
  "require": {
    "wbrowar/adminbar": "dev-4.x-craft-4"
  },
}

If you don't want to install the beta, then please let me know if you have any luck with using double quotes or by changing the font stack. If one of those options works for you I'll look into updating the default.

mscherr-fastspot commented 10 months ago

re - single to double quotes:

I get the same error using 3.2.0:

:root {
    --adminbar-font-stack: "JJannon Display", Garamond, Baskerville, "Baskerville Old Face", "Hoefler Text", "Times New Roman", serif";
    --adminbar-bg: #0c2142;
}

CleanShot 2023-12-01 at 12 41 56

re - dev-4.x-craft-4 version

I installed, but got an error on every page; I wasn't able to debug further at this time, I'm sorry:

CleanShot 2023-12-01 at 12 38 13

I am ok for now; it's not the biggest deal in the world. I think I'll just leave the font family as the default one. I appreciate you looking into it though.

wbrowar commented 10 months ago

Hi, @mscherr-fastspot, I'm sorry, I can’t seem to re-create this. I'm using a PHP 8.0, and a MySQL based DB. I've tried different combinations of Custom CSS settings to add in singe quotes, double quotes, and some unfinished quotes.

Screenshot 2023-12-02 at 10 11 28 AM

My only other thought is it could be due to another module or maybe some setting that is trying to bundle your CSS that comes from Twig/Craft.

Regarding the Beta version, I updated it with a new version last night. I didn't have anything in there that specifically addresses this issue of it crashing, but something in there might make it work better.

mscherr-fastspot commented 10 months ago

Here's my info if it helps:

CleanShot 2023-12-04 at 08 51 56

But you're right, it might be something on my end then with another plugin. You can close this ticket if you would like. Thanks again for looking into it. If you can't replicate, I'm sure it's from another plugin or some of my own code.

If I end up debugging it further and finding anything I'll let you know!

wbrowar commented 10 months ago

Sounds good, @mscherr-fastspot. I'll close it for now, but I'm going to get my development environment working on PHP 8.2 and when I do that I'll make sure to test my settings again.