Elements webform_codemirror and webform_rating require the installation of JS libraries to work properly, but this is not mentioned on admin/structure/webform/config/elements where these elements can be enabled. I suggest that the description for these elements mention that the user will need to visit admin/structure/webform/config/libraries to enable the corresponding library.

Issue fork webform-3260486

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Liam Morland created an issue. See original summary.

jrockowitz’s picture

Status: Active » Closed (won't fix)

Information about external libraries is documented via https://www.drupal.org/docs/contributed-modules/webform/webform-libraries and /admin/structure/webform/config/libraries

Liam Morland’s picture

Here is an example of the problem as I see it: A user enables webform_rating element type. They add one to a form and all they see is a generic slider. They would have to know to go to a different page and enable the jQuery: RateIt library to get the star ratings that are intended by this module. To solve the problem, the description on admin/structure/webform/config/elements could say "This element requires that you enable the jQuery: RateIt library."

jrockowitz’s picture

I thought there was code to remove elements when the dependent library is disabled.

Liam Morland’s picture

I just enabled webform_rating and jQuery: RateIt and then disabled the latter. The former was still enabled. (Unless it is new; the test I just did was on WF 6.1. Let me know if you want met to try it on 6.2.)

Even if that worked, that doesn't mean it works the other way around: Enabling webform_rating would need to enable jQuery: RateIt. But that shouldn't happen without warning the user.

jrockowitz’s picture

Status: Closed (won't fix) » Active

The webform_rating and webform_signature elements have this problem/challenge.

In \Drupal\webform\WebformLibrariesManager::initLibraries the related elements for each library is tracked. This information would be used to append the warning to the /admin/structure/webform/config/elements page.

If the signature elements case if the library is disabled the element stops working. This is not good.

A few thoughts...

  • We should come up with a solution that does not cause regressions.
  • Should we not allow a library to be disabled if the associated element is used on any webforms?
  • If a library is disabled the associated element should be not available to add to webforms?
Liam Morland’s picture

As I understand it, jQuery: RateIt is only used with webform_rating. Perhaps it should not appear at all on the libraries page. It should be considered part of webform_rating and turn on and off with it. There should be a notice with each element type that has such a JS dependency. webform_codemirror should probably be the same.

Webform has three ways that functionality can be turned on and off: Element types, libraries, and sub-modules. It may be confusing to have three. One solution would be to move everything into sub-modules. For example, a webform_rating sub-module would provide the element type and the JS to support it.

jrockowitz’s picture

I think moving elements into submodule could be an okay solution but it requires a bit work and introduces the risk of regressions.

I don't have the bandwidth to do that level of refactoring or support that major of a change right now.

Liam Morland’s picture

Yes, it is a big change. Changes to the item descriptions is an easy way to accomplish some of this.

jrockowitz’s picture

Version: 6.2.x-dev » 6.1.x-dev
jrockowitz’s picture

Status: Active » Needs review
FileSize
3.73 KB

I update the element description to recognize which external library is being used.

Status: Needs review » Needs work

The last submitted patch, 11: 3260486-10.patch, failed testing. View results

jrockowitz’s picture

Status: Needs work » Needs review
FileSize
5.4 KB
Liam Morland’s picture

Reading the patch, it looks good. Perhaps the library names should be links instead of having the URL in brackets after it.

  • jrockowitz authored 73668dc on 6.1.x
    Issue #3260486 by jrockowitz: Document in UI elements that need a JS...

  • jrockowitz authored 73668dc on 6.x
    Issue #3260486 by jrockowitz: Document in UI elements that need a JS...

  • jrockowitz authored 73668dc on 6.2.x
    Issue #3260486 by jrockowitz: Document in UI elements that need a JS...
jrockowitz’s picture

Status: Needs review » Fixed

I was able to add links to annotations. I committed the patch.

Status: Fixed » Closed (fixed)

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