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

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

antoineh created an issue. See original summary.

immoreel’s picture

Patch works, thanks!

immoreel’s picture

Status: Needs review » Reviewed & tested by the community
immoreel’s picture

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

sonam_sharma made their first commit to this issue’s fork.

ant1’s picture

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

tijsdeboeck’s picture

Related issues: +#3368202: Update README

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

jsheffers’s picture

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

idas’s picture

Composer didn't install the library for me, but by applying this patch, which fixes the issues with the "once" element, and putting the files in the library manually, everything works smoothly.

jnettik’s picture

StatusFileSize
new2.52 KB

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

justin2pin’s picture

Status: Reviewed & tested by the community » Fixed

Committed with patch from #10.

Status: Fixed » Closed (fixed)

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

alison’s picture

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

alison’s picture

StatusFileSize
new936 bytes
new1.93 KB

⚠️ [EDIT - I made mistakes in this patch! - new version on the way - please ignore this entire comment!]

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. [EDIT: It also applies cleanly to 1.1.0.]

(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).

alison’s picture

Version: 1.0.0-alpha2 » 1.1.x-dev
StatusFileSize
new917 bytes
new1.76 KB
new600 bytes

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.

ant1’s picture

You're totally right. This patch didn't went through. Pity we cannot reinstate this issue.
Also checked patch on #15 and it does the job more cleanly than older patches.

senthilmohith’s picture

I have created this patch for the latest version 1.1.x. I tried this and it's working as expected. Please refer the attached screenshot.
Note: preferredFormat changed from "rgb" to "hex". This format will be helpful for the content authors.

allahnoor turab’s picture

Still issue with latest version of drupal 11.2.3.
Has anyone tested