Problem/Motivation
jQuery UI Dialog and Autocomplete both need to be shimmed: #2158943: Add a native dialog element to deprecate the jQuery UI dialog #3076171: Provide a new library to replace jQuery UI autocomplete
Both features use jQuery UI position(). Instead of including position() in the scope of either of those issues, it should be scoped to its own issue as all of these jUI shim issues are already quite large, and this can easily get its own scope.
Steps to reproduce
Proposed resolution
Create a custom version of jQuery UI position in /misc, to be used instead of the position within jQuery UI. It will be modified to meet Drupal coding standards and so that it extends jQuery instead of jQuery UI. This only requires changing assumptions regarding the presence of $.ui to non-UI jQuery.
Because jQuery UI position does not have any fixed dependencies on other parts of jQuery UI, making a custom version for use in core is acceptably maintainable.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | postest.png | 14.6 KB | zrpnr |
| #7 | interdiff_5-7.txt | 45.28 KB | bnjmnm |
| #7 | 3201170-7.patch | 69.41 KB | bnjmnm |
| #5 | 3201170-5-REROLL.patch | 62.59 KB | bnjmnm |
| #3 | 3201170-3.patch | 62.73 KB | bnjmnm |
Issue fork drupal-3201170
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
bnjmnmjquery.ui.position:library. There are still several libraries that callposition-min.jsdirectly that would need this replaced with the shim. That's a next stepmy:, at:, of:, collision:(other thanof:accepting an Event as a value). Currently,using:, within:are not shimmed.Comment #3
bnjmnmNightwatch tests should work on DrupalCI now. For a task this large there is certainly more to do (much of which is elaborated on in the prior comment), but setting to needs review as it is a large task that should get additional eyes on it.
In addition to the steps mentioned, I plan to do another round of comments as the logic of the shim is complex.
Comment #4
bnjmnmAlready spotted another requirement. Contextual links has a call
That can result in
I suspect this is because there should be a default value for "of". Will include in next steps.
Comment #5
bnjmnmNeeded a reroll
Comment #6
lauriiiWould it be possible to add some integration tests with dialog for example? I think it could be simple since we already have quite extensive test coverage here.
Should we find a more generic name to call the element than tip?
There's over 100 lines inside this if statement which makes reading this a bit challenging 😅 Would it be possible to move at least some of this outside here?
IMO this would be easier to read if the if condition was flipped especially given that the comment explaining this is now in the else statement.
Any thoughts on running these tests also on RTL?
Comment #7
bnjmnmThis addresses #6.2-4 and some nontrivial refactoring to make it more readable.
Will look into the tests mentioned in #6.1 and #6.5
Comment #9
nod_Didn't go through the whole patch yet, only looked at the js shim
Comment #10
nod_Taking a step back I'm not sure what is supposed to happen here.
The jquery ui position is a ~560 lines script depends only on jQuery (and "vesion"), it improve the existing jQuery position method: https://git.drupalcode.org/project/drupal/-/blob/9.2.x/core/assets/vendo...
This patch introduces a ~520 lines script that depends on jquery and popperjs.
To me this suggest the complexity of this script is not in how it's implemented but in what the API supports.
What is the net improvement we're looking for? If we do that simply because we want to deprecate jquery ui, why not take the position script used for shims and remove it when we remove the shims no?
Comment #11
nod_Following a meeting with bnjmnm, lauriii, gabor, and myself, todo:
Comment #12
bnjmnmUpdated IS and code to reflect the approach mentioned in #11
Comment #13
nod_Couple of details
Comment #14
nod_Looking good, haven't gone though the tests yet
Comment #15
zrpnrThis is truly impressive work, especially considering you created the Nightwatch tests to match to match the jQuery UI qUnit tests.
To compare I tested the new code in position.es6.js and postion.js against the original qUnit tests and both pass.
Just the
with scrollbarsqUnit test was missing from the Nightwatch tests, but it looks like you already have thescrollxelement in place.Really appreciated the updated postion.es6.js style, especially the destructuring and prettier formatting for ternary statements.
Also very thoughtful to add comments!
Since the code is being "updated" - why not also fix some of the variable names?
hindexfor example could be camelCased then it would not need to be added to dictionary.txtdestructurewas unused.These are all in just in test files and could be camelCased or renamed.
These are internal variable names and could also be renamed or camelCased to avoid adding to dictionary.txt
I think the only word that needs to be added is
flipfitsince that's one of the exposed options in position.Comment #16
bnjmnmAll current MR feedback addressed.
Comment #17
bnjmnmAdded the
with scrollbarstest. Per #15Comment #18
zrpnrMy only concerns were addressed, by adding the
with scrollbarstest and removing all the unnecessary additions to dictionary.txt, and good call re-adding flipfit back as-is, since that is part of the API. This still passes all the original qUnit tests so I'm confident the Nightwatch tests match.I also found it particularly notable that you created Nightwatch tests to match the visual tests in jQuery UI- the originals weren't even automated!
Goes by so fast that I had to make a screen recording to be able to appreciate it :)
Comment #19
nod_Confirmed that the code has only cosmetic changes between jquery ui and our version. It's the least amount of work in the least disruptive way while still securing our side of things.
Tests are very exhaustive and most if not all the position permutations are tested.
Huge amount of work, well done.
RTBC +1
Comment #21
lauriiiCommitted 9289782 and pushed to 9.2.x. Thanks!