presseddigital / colorit

A slick color picker fieldtype plugin for the Craft CMS control panel
Other
21 stars 8 forks source link

Preset colours not showing in edit page #36

Open billymedia opened 3 years ago

billymedia commented 3 years ago

As described in this thread: https://github.com/presseddigital/colorit/issues/32

When you create a colorit field with the colours preset, the colours dont appear when editing the entry.

I saw that you posted an update with a fix, but i am using Colorit 1.1.2.1 with Craft CMS 3.7.6 and its still showing the issue.

What can i do to fix this?

proimage commented 3 years ago

@ben-callaway I'm now getting this issue as well on a staging server, but not in my local version of the site.

cdfwebsolutions commented 3 years ago

The issue appears to be that the field outputs in the CP an extra '#' character before the hex code (e.g., ##336699 instead of #336699)

proimage commented 3 years ago

I'm actually seeing them without any # symbol on my end. image I wonder if the setting to control the output format is affecting things in the backend.

cdfwebsolutions commented 3 years ago

Hmmm ... I had to set the presets to output in 454545 (no # symbol) format to avoid getting double ## on the front-end, but I still get the double ## in the CP on Craft 3.6.11.2 with latest Colorit.

I thought I might have to do something like #{{ myColorField | slice(-6) }} everywhere I had a Colorit field, but it seems okay on the front-end with the 454545 format.

proimage commented 3 years ago

Yeah, something's definitely wonky.

proimage commented 3 years ago

Can this get bumped up in priority, @ben-callaway or @samhibberd ?

proimage commented 3 years ago

Possible fix: Edit and re-save any color presets you have.

EDIT: Note that you can even do this on live sites that have admin changes disabled... just navigate to yoursite.com/admin/colorit/presets manually.

BallardB commented 3 years ago

Bumping this post up because I am still seeing the issue. I've tried editing and re-saving presets but that did not fix the issue.

Would love to use this plugin on a production site for a client but this bug is really preventing us from using it at all.

Any updates on when this might be fixed?

ben-callaway commented 3 years ago

Sorry @BallardB - will take another look!

BallardB commented 3 years ago

Thanks @ben-callaway I really appreciate it!

proimage commented 3 years ago

Any news on this?

mcjackson18 commented 2 years ago

Hi @ben-callaway, is there any update on this?

Not fully tested this yet, as a quick fix changing line 26 in /templates/_fields/colorit/input.twig to the below is working for me

{% set processedColor = field.allowOpacity and opacity < 100 ? craft.colorit.colors.hexToRgba(paletteColor.color, opacity) : ('#' in paletteColor.color ? paletteColor.color : '#' ~ paletteColor.color) %}

cmalven commented 2 years ago

I'm experiencing the same issue, and this is preventing me from saving any changes to a matrix block, because all preset colors will be lost and break the site.

taher-amici commented 2 years ago

Hi For removed ## in frontend code fields/coloritField.twig at getPalette() in 305

if (strpos($palette[$paletteColor['handle']]['color'], '#') !== false) {
    $palette[$paletteColor['handle']]['color'] = trim($palette[$paletteColor['handle']]['color'], '#');
}
sgtpenguin commented 2 years ago

@ben-callaway I am experiencing this issue after updating to 3.0.0

Also, downgrading back to 1.0.9.3 now throws this error:

Screen Shot 2022-10-06 at 12 29 19 PM
pascal-blaser commented 1 year ago

Any updates? Just ran into the same issue again.