Problem/Motivation
We're using this module resp. the build in Spectrum widget in a lot of paragraph and content types. After update Drupal Core to version 8.6.1 all worked fine. In the next step I decide to perform pending module updates, but after updating the color_field module to version 8.x-2.0 the spectrum color widgets no longer work.
I thought it depends on our special usecase but I can reproduce this by the following steps:
- Install a brand new Drupal 8.6.2-dev with standard profile
- Install stable version 8.x-2.0 of this module
- Install spectrum library at
/libraries/spectrum
- Add a color field to the content-type Article
- Use
Color spectrum
as widget type with default settings on the form display - Try to create a new article. Result:
Reverting to 8.x-2.0-rc4 with drush dl color_field --select
results in a correct behavior:
After some investigation the problem is probably situated in the render process of the field widgets: the items on 8.x-2.0-rc4 are wrapped in a <div class="js-color-field-widget-spectrum">…</div>
for instance. This wrapper is missing with 8.x-2.0.
Proposed resolution
Working widgets with stable release on Drupal 8.6.x
User interface changes
No.
API changes
It depends, but I think: should be necessary.
Data model changes
No.
Comment | File | Size | Author |
---|---|---|---|
#23 | 3002836-widget-improvement-23.patch | 1.28 KB | NickDickinsonWilde |
| |||
#22 | 3002836-widget-improvement-22.patch | 483 bytes | NickDickinsonWilde |
#7 | no_functionality_of_almost_all_widgets-3002836-7.patch | 744 bytes | cbildstein |
Comments
Comment #2
anpolimusI've faced with the same problem at my project.
Quick investigation showed that libraries are not attaching in case of paragraph ajax insert.
Comment #3
anpolimusSomeone deleted templates after RC4
https://cgit.drupalcode.org/color_field/tree/templates/color-field-widge...
here template for spectrum is exist
Comment #4
anpolimusIssue, where we have broken spectrum
https://www.drupal.org/project/color_field/issues/2961036#comment-12819876
Comment #5
jmuzz CreditAttribution: jmuzz commentedAdd
$element['#type'] = 'container';
at line 135 in ColorFieldWidgetSpectrum.php
Comment #6
charlietoleary CreditAttribution: charlietoleary at Atech commentedAlso, having this issue.
I have also found that if you add a new color field to your entity and select the spectrum widget, the other field's widgets start working. If you remove the new field the widgets break again though.
jmuzz's change at 135 in ColorFieldWidgetSpectrum.php fixed the issue for me.
Comment #7
cbildstein CreditAttribution: cbildstein at Acro Commerce commentedPatch for setting ColorFieldWidgetSpectrum element type.
Comment #8
anpolimusComment #10
anpolimusPatch at #7 is tested by me locally.
It fixes spectrum issue but fails tests.
We need to investigate is it tests problem or something is broken also and needs to be fixed during this issue.
Comment #11
anpolimusJust followed automatic tests manually and noticed that field is not rendering at content type.
That's why tests are failed.
In addition to broken widget we have problem with broken field formatter.
Comment #12
rwam CreditAttribution: rwam commentedHi @all and thank you for working on this. Patch #7 solves this for me.
I've changed the issue title and summary because of a missing dependency to the jQuery Simple Color library. Fixed it and get a working grid widget. Sorry for that.
Comment #13
anpolimusMy second test was wrong - edit and display of color field are working properly.
We need to analyse why ColorFieldWidgetJavascriptTests is failed.
Comment #14
trebormcPatch #7 solves this for me.
Comment #15
maticb CreditAttribution: maticb commentedPatch #7 fixes the problem on the widget for me.
Comment #16
ojardila CreditAttribution: ojardila commentedPatch #7 also worked to me.
Comment #17
saschaeggiPatch #7 solves the problem for me as well
Comment #18
rgpublicPatch #7 also works for me. Sad that you cannot just use stuff like this without always running into such hassle. And it always takes forever and a day until such stuff is finally committed even if it's a single-line change and the module is completely broken without it. Sigh.
Comment #19
7thkey CreditAttribution: 7thkey commentedPatch #7 works for me, using Drupal core 8.7.10 and paragraphs 1.10.
Comment #20
maticb CreditAttribution: maticb commentedComment #21
NickDickinsonWildeThanks for the patch and discussion.
Can't commit a patch that breaks tests - need to fix tests. Will try and resolve this this weekend.
Comment #22
NickDickinsonWildeComment #23
NickDickinsonWildeadjust test
Comment #25
NickDickinsonWildeComment #26
NickDickinsonWildeThanks y'all!
Comment #28
travisc CreditAttribution: travisc as a volunteer commentedI've tried both 8.2.2. and 8.2.x and still I'm not picking up the widget. Currently on Drupal 8.8.2Sorry my bad, you need to make sure to edit the form display and select the widget, for instance on my paragraph i have a color field so go to /admin/structure/paragraphs_type/div_class_color_selector/form-display and select your widget after you have added the field to your form.