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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rwam created an issue. See original summary.

anpolimus’s picture

I've faced with the same problem at my project.
Quick investigation showed that libraries are not attaching in case of paragraph ajax insert.

anpolimus’s picture

Someone deleted templates after RC4
https://cgit.drupalcode.org/color_field/tree/templates/color-field-widge...
here template for spectrum is exist

anpolimus’s picture

jmuzz’s picture

Add

$element['#type'] = 'container';

at line 135 in ColorFieldWidgetSpectrum.php

charlietoleary’s picture

Also, 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.

cbildstein’s picture

anpolimus’s picture

Status: Active » Needs review

Status: Needs review » Needs work
anpolimus’s picture

Patch 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.

anpolimus’s picture

Just 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.

rwam’s picture

Title: No functionality of almost all widgets on Drupal 8.6.x with latest stable or dev » No functionality of the Spectrum widget on Drupal 8.6.x with latest stable or dev
Issue summary: View changes

Hi @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.

anpolimus’s picture

My second test was wrong - edit and display of color field are working properly.
We need to analyse why ColorFieldWidgetJavascriptTests is failed.

trebormc’s picture

Patch #7 solves this for me.

maticb’s picture

Patch #7 fixes the problem on the widget for me.

ojardila’s picture

Patch #7 also worked to me.

saschaeggi’s picture

Patch #7 solves the problem for me as well

rgpublic’s picture

Patch #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.

7thkey’s picture

Patch #7 works for me, using Drupal core 8.7.10 and paragraphs 1.10.

maticb’s picture

Status: Needs work » Reviewed & tested by the community
NickDickinsonWilde’s picture

Assigned: Unassigned » NickDickinsonWilde
Status: Reviewed & tested by the community » Needs work

Thanks for the patch and discussion.
Can't commit a patch that breaks tests - need to fix tests. Will try and resolve this this weekend.

NickDickinsonWilde’s picture

Assigned: NickDickinsonWilde » Unassigned
Status: Needs work » Needs review
FileSize
483 bytes
NickDickinsonWilde’s picture

  • NickWilde committed 96f210d on 8.x-2.x
    Issue #3002836 by NickWilde, cbildstein, rwam: No functionality of the...
NickDickinsonWilde’s picture

Status: Needs review » Fixed
NickDickinsonWilde’s picture

Thanks y'all!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

travisc’s picture

I've tried both 8.2.2. and 8.2.x and still I'm not picking up the widget. Currently on Drupal 8.8.2

Sorry 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.