Problem/Motivation
Change record: Remove jQuery dependency from the once feature
Steps to reproduce
- install Drupal 10
- composer require drupal/typed_data:^1.x-dev@dev
- composer require drupal/rules:^3.x-dev@dev
- drush pm:enable rules
- create a new rule
- the data selector never shows autocompleted results
Notes
- the js/autocomplete.js script uses jQuery once which is no more supported in Drupal 10 and should be replaced with once
- JavaScript console says "Uncaught TypeError: $(...).find(...).once is not a function" at line 110.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | interdiff-10-12.txt | 713 bytes | tr |
| #12 | 3338673-12-jquery-once.patch | 9.1 KB | tr |
Issue fork rules-3338673
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
Comment #2
tr commented@Zigazou: Can you supply a patch?
Comment #3
_pratik_Comment #4
zigazou commentedHi!
After applying the patch, the '$' variable is no more available and triggers the following message:
Comment #5
tr commentedWe use jquery.once in three different .js files:
but it appears the above patch only modifies one of these (autocomplete.js).
According to the comments in autocomplete.js, Rules autocomplete.js was forked from core misc/autocomplete.js. I would have to do research to find out why it was forked, and what Rules is doing different, but if at all possible the Rules version should be changed the same way as the core version.
For reference, jQuery once was removed from core autocomplete in #3183149: Deprecate jquery.once and use the new once lib.
For this patch, I would also like to evaluate the dependencies for all of these .js files. For example, with autocomplete.js, right now we use:
but I suspect that most of these are not needed and should be removed. Same with the other .js.
Comment #6
zigazou commentedHi!
Following comment #5 saying rules/autocomplete.js was forked, I did the same with Drupal 10 core/misc/autocomplete.js.
From what I saw, the custom autocomplete.js:
I did not look at debug.js and rules_ui_listing.js.
Can someone please review the patch?
Comment #7
tr commentedAs you can see from the tests, your patch didn't fix any of the failures that are caused by using the (now removed) jquery-once library.
Comment #8
tr commentedrules_ui.listing.js was fixed in #3346889: [meta] Update rules_ui.listing.js
We still need to fix both debug.js and autocomplete.js
Comment #9
tr commentedHere's a re-roll with fixes to debug.js.
Comment #10
tr commentedThe remaining D10 error is not related to this patch.
Here's some more cleanup.
Note - autocomplete.js and debug.js both require manual testing, because we don't have any test cases that use these. I could really use help manually testing these.
Comment #11
hongqing commentedI tested patch #10, it works well with PHP 8.1, MySql 5.7, and Drupal 10.0.9. Thanks.
Comment #12
tr commentedFixed two coding standards errors and added documentation comments to explain why autocomplete.js was forked, based on what @Zigazou said in #6.
Comment #15
keshavv commentedcreated MR for the patch please review.
Comment #17
tr commentedCommitted.
Comment #18
tr commented