Spectrum not working

Created on 12 June 2023, over 1 year ago
Updated 12 June 2024, 4 months ago

Problem/Motivation

It seems that Spectrum doesn't apply due to two reasons:
First of all, it seems to be expected that we require the package ourselves? It is unclear as it is never stated in the documentation.
Second, the initiation of Spectrum is never triggered due to a error (once() doesn't exists).

Proposed resolution

- Rewrite color-spectrum.jquery.js to actually work.
- Update libraries to effectively apply external code ( https://www.drupal.org/docs/develop/creating-modules/adding-assets-css-j... )

🐛 Bug report
Status

Fixed

Version

1.1

Component

Code

Created by

🇧🇪Belgium antoineh Mechelen, 🇧🇪

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @antoineh
  • 🇳🇱Netherlands immoreel

    Patch works, thanks!

  • Status changed to RTBC about 1 year ago
  • 🇳🇱Netherlands immoreel

    Oh also: the documentation could use an update about how to install spectrum...

  • First commit to issue fork.
  • 🇧🇪Belgium antoineh Mechelen, 🇧🇪

    #4: With this patch, it should not be needed as it is done automatticaly.

  • 🇧🇪Belgium tijsdeboeck Antwerp 🇧🇪 🇪🇺 🌎

    Re #4 &#5, it might be useful to add it in the readme, just in case someone isn't using Composer?

  • 🇺🇸United States jsheffers

    This won't apply to dev, but I was able to get it working manually.

  • 🇮🇹Italy Idas Torino

    console log:
    color-spectrum.jquery.js?v=1.8.0:15 Uncaught TypeError: Cannot set properties of undefined (setting 'optionPluginColorSpectrum')

  • 🇺🇸United States jnettik Denver, CO

    I updated this patch so it works against latest dev. Issue is the .info.yml file was trying to modify the packaged version.

  • Status changed to Fixed 6 months ago
  • 🇺🇸United States justin2pin

    Committed with patch from #10.

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

  • 🇺🇸United States alison

    Is it possible #10 didn't make it in after all?

    -------

    I don't see this fix in the 1.1.x commit log on GitLab (or the 1.0.x commit log), or in the June 2024 1.1.0 release (and actually, I don't see a commit link in this issue thread).

    So, I looked at the Style Options project on GitLab, and I don't see the changes in any of the relevant files there, either (I figured, sometimes maintainers make the changes manually / in commits not directly tied to issue threads, due to limited time).

  • 🇺🇸United States alison

    I did some more investigating!

    TL;DR: Attached is a new patch that does "what's left" from #10. In my testing, this patch applies cleanly to both 1.1.x-dev and 1.0.x-dev.

    (I can't change the status back to "needs review," but hopefully this will help anyone who stumbles upon this issue in the meantime!)

    More details:

    1️⃣ Looks like this commit, March 19, 2024: https://git.drupalcode.org/project/style_options/-/commit/5736bd1fa7b7d8...

    • does the changes to js/color-spectrum.jquery.js that were in the patch on #10, in a slightly different way, but still does them
    • AND it adds the core/once dependency to style_options.libraries.yml

    2️⃣ This commit, April 21, 2024: https://git.drupalcode.org/project/style_options/-/commit/112a40a8b843b1...

    does the change to style_options.info.yml that was in the patch on #10 (simply updating core_version_requirement)

    So, the attached patch does "the rest of what was in #10" (other changes to style_options.libraries.yml).

  • 🇺🇸United States alison

    Terribly sorry for my mistakes in #14 and subsequent thread clutter!

    This new-new patch (#15) only does two things:

    • Use spectrum 1.8.0, from the CDN (like #10).
    • Re-order the dependency libraries to be alphabetical (like #10).

    In my testing, this patch (#15) applies cleanly to 1.1.x-dev, 1.0.x-dev, and 1.1.0, and the Spectrum functionality is working properly on my site.

    Issue status

    Spectrum is still broken for me (1.1.0 and 1.1.x-dev), because the Spectrum library version and external source part of this issue (and the remaining part of the patch on #10) hasn't been committed/fixed, so that's why I'm posting on this thread rather than a new thread. Of course, I can't change the issue status back to "needs review," so maybe this is a bad idea... but hopefully this will help anyone who stumbles upon this issue in the meantime?

    Excessive details you probably don't need

    "just in case"...

    #15 vs. #10

    TL;DR: #10 no longer applied because of two "conflicting" commits:

    1️⃣ Commit #5736bd1 (March 19, 2024), which conflicted with #10 because it...

    • added the core/once dependency to style_options.libraries.yml
    • replaced deprecated use of jQuery once, in js/color-spectrum.jquery.js

    This new patch (#15) doesn't make any changes to js/color-spectrum.jquery.js -- in my testing, Style Options + Spectrum work fine on my site leaving this JS file as-is. (I'm guessing the changes to js/color-spectrum.jquery.js in earlier versions of this patch were only necessary with the deprecated jQuery implementation?)

    2️⃣ Commit #112a40a (April 21, 2024), which conflicted with #10 because it...

    • updated core_version_requirement in style_options.info.yml

    In conclusion, this new patch (#15) simply updates the Spectrum library version (1.6.0 => 1.8.0), and uses the external/CDN library.

Production build 0.71.5 2024