Drupal 10 was released on 14 December 2022. Let's make this module D10-compatible!
Callouts:
- This module uses jquery.once, which is removed in D10. Change the library requirement and update the actual JS (note that there is also an npm/gulp build that needs to be run.
- The automated tests need to be refactored to use a different theme, such as Olivero
- The automated tests include integration with Webform. This test may need to be reworked to be compliant with Webform 6.2.x
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | media_library_form_element-add-access-check.patch | 561 bytes | levmyshkin |
| #16 | 3304993-d10_16.patch | 538 bytes | mark_fullmer |
| #8 | media_library_form_element-d10-compatibility-3304993-8.patch | 259.73 KB | mark_fullmer |
Issue fork media_library_form_element-3304993
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
levmyshkinHere is a patch for .info.yml file
Comment #5
mark_fullmerThere are some additional elements that need to be addressed for this to be D10 compatible. I added some updates to the test syntax. The remaining item there would be to replace the usage of jQuery in media_library.form-element.js with Drupal core equivalents (i.e., standalone core/once).
Additionally, this module provides integration with Webform, which does not yet have a D10 release (it's close: #3262067: [META] Make Webform compatible with Drupal 10. I was able to functionally test this using the staged changes in Webform and everything looks good, but automated tests won't pass on drupal.org until Webform has a D10-compatible release.
Setting this to "Needs work" for the jQuery conversion.
Comment #6
levmyshkinHi mark_fullmer, I replaced jQuery once with javascript once in 3304993-drupal-10-support branch. Unfortunately Webform module is still not available for Drupal 10:
https://www.drupal.org/project/webform/issues/3262067#comment-14819666
Also I changed core_version_requirement to ^9.2 || ^10, becuase javascript once() was added only in 9.2 Drupal core:
https://www.drupal.org/node/3158256
Comment #7
levmyshkinComment #8
mark_fullmerComment #9
mark_fullmerComment #11
rajab natshahComment #12
smustgrave commentedTested this using the upgrade status and all issues have been addressed.
Once this is merged could there be a release as this is a block for bootstrap_styles + bootstrap_layout_builder.
Comment #13
phenaproximaIt would be better to change this test to use Stark, but that's out of scope here.
Why is this added?
Comment #14
mark_fullmerAgreed on both counts -- Stark would be better, but since the existing tests expect certain CSS classes to be present, I was trying to change as little as possible to keep the scope at D10 compatibility.
The switch to Olivero caused the visibility of elements within the Media Library to go off-screen, due to differences in CSS margins. The test failure was, as I recall, "Element not clickable at this point." Making the screen width in the test bigger ensures that all elements in the Media Library are visible. The other method I'm aware of for handling this is to use JS to scroll the item into view a la something like the below code, but again, I was rying to change as little as possible.
Comment #15
phenaproximaOkay, makes sense to me. Thanks, @mark_fullmer.
Nothing else really raised a red flag, and tests appear to be passing on Drupal 9 and 10. Not sure I have anything to complain about, so I've committed and pushed to 2.x. Thanks everyone!
Comment #16
mark_fullmerI notice that the final commit does not include the accessCheck to the media query suggested in https://www.drupal.org/project/media_library_form_element/issues/3304993.... Is this not needed?
Comment #17
levmyshkinI added accessCheck() before to avoid warnings in PHP Unit, but it looks like we don't force to use it anymore:
https://www.drupal.org/node/3201242#comment-14650219
I have ran tests for PHP init in media_library_form_element without accessCheck() and it didn't show any warnings. So I think we can remove accessCheck() for now or set it accessCheck(FALSE).
Comment #18
mark_fullmerI think we should add accessCheck(FALSE), taking the statement from the change notice at its word:
Comment #19
levmyshkinHi mark_fullmer, I'm confusing how to add changes in current git branches for this ticket. I will attach a patch for accessCheck(FALSE) here.
Comment #20
mark_fullmerThe patch in #19 looks good. Note that this change is present in the getTestValues() method, which is implementing an expected method from WebFormElementBase (https://git.drupalcode.org/project/webform/-/blob/6.1.x/src/Plugin/Webfo...), but that it is only used in the context of testing.
Comment #21
levmyshkinHi mark_fullmer, thank you! Do you have access to merge pull requests and release new Media Library Form API Element version with Drupal 10 support?
Comment #23
mark_fullmerI have commit access but I don't have the ability to cut a release. I've committed the change and marked this issue as fixed.
Since this is a pro-forma change that only affects (theoretical) testing, I don't think it's necessary to get it into a release immediately for people trying to use this with D10.
Thanks, levmyshkin!