Problem/Motivation

webform.element.color.js calls jQuery UI's $.fn.uniqueId() to assign an id to the generated color-output input. uniqueId() is a jQuery UI method, not part of jQuery core. Drupal 11 ships jQuery 4, which drops the old jQuery UI method shims, so on any page that renders a webform color element the script throws uniqueId is not a function and the color output field is never enhanced.

The call is still present in 6.2.x and 6.3.x. #3512816: jQuery.isFunction is removed in jQuery 4.0+ fixed $.isFunction in another file but didn't touch this one.

Steps to reproduce

On a Drupal 11 site, add a color element to a webform and view the form. The console shows the TypeError and the color output field doesn't render.

Proposed resolution

Replace the single uniqueId() call with a module-local incrementing counter to generate the id. Patch attached.

Issue fork webform-3605746

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

dylan donkersgoed created an issue. See original summary.

liam morland’s picture

Status: Needs review » Needs work
Issue tags: +Needs merge request

Thanks for the patch. Please create a merge request.

liam morland’s picture

Issue summary: View changes

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

charlliequadros’s picture

Hi @liam morland,

I made a small change to the patch: instead of using ++webformColorOutputId, I changed it to webformColorOutputId += 1.

I made this change because ESLint may generate a warning for the use of ++, so I thought it would be better to avoid introducing that warning. I also separated the code a little more to improve readability.

charlliequadros’s picture

Status: Needs work » Needs review