Problem/Motivation
- jQuery UI has reached end-of-life, so it is being removed from Drupal core.
- jQuery UI Dialog is very much woven into Drupal core, making it necessary to provide a Backwards Compatible shim, which is being worked on here: #2158943: PP-1 Add a native dialog element using HTMX to deprecate the jQuery UI dialog
- jQuery UI Dialog includes the resizable() jQuery UI interaction, which makes it possible to drag a dialog by its edges to resize it.
- Resizable is a complex feature on its own. Definitely enough to merit this separate issue.
Steps to reproduce
Proposed resolution
I see two different sets of choices that need to be made in order to settle on an approach:
Is it necessary to keep resizable functionality around?
So far, Drupal core's replacements for jQuery UI functionality have provided identical or better functionality, and gone to lengths to support backwards compatibility. Examples: #2158943: PP-1 Add a native dialog element using HTMX to deprecate the jQuery UI dialog, #3076171: Provide a new library to replace jQuery UI autocomplete, #3201170: Address jQuery UI position dependency. In the case of Resizable, however, it's worth discussing if a replacement is needed. Modal dialogs are already non-resizable, and it's unclear how many users are even aware that off-canvas dialogs are resizable.
Skipping pros:Feature may be largely unused. This would eliminate the need for a complex shim and additional code/libraries to maintain.
Skipping cons:It's possible this is an important feature for some users. It would be removing functionality that was previously there.
If we do maintain the functionality, how do we replace it?
- Find a replacement library and provide a backwards compatible shim, keeping in mind that shimming something like resizable would necessitate a very complex shim
- Create a custom replacement and provide a backwards compatible shim, also keeping in mind that something like resizable would necessitate a very complex shim
- Make jQuery UI resizable the only part of the jQuery UI custom fork we keep in Drupal core. This would require 6 jQuery UI assets:
"./mouse","../disable-selection","../plugin","../version","../widget" - The Drupal 9 jQuery UI dialog shim can use jQuery UI resizable, but it will include a deprecation warning that the ability to resize will not be provided in Drupal 10.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #29 | 3201835-nr-bot.txt | 1.2 KB | needs-review-queue-bot |
| #25 | after.gif | 4.88 MB | finnsky |
| #25 | before.gif | 2.99 MB | finnsky |
| #14 | resizable-dialog-stark-works-ok.png | 126.56 KB | bnjmnm |
| #14 | claro-vanish.gif | 298.55 KB | bnjmnm |
Issue fork drupal-3201835
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
bnjmnmComment #3
nod_I'd vote for removing it. When I needed to resize something is because there were bugs in the positioning, never for a legitimate UX reason. I don't know how other people interact with it though.
Comment #4
bnjmnmI think there may be a legitimate need for horizontally resizable off-canvas dialogs. Even anecdotally, I've seen Layout Builder users increase the width of off-canvas dialogs with long forms or CKEditor. For this reason, I think off-canvas dialogs should remain resizable. If even bnjmnm the hermit has seen this in the outside world, there are probably enough users enjoying the feature that it needs still be available.
To keep this specific functionality without the overhead of shimming+replicating yet another massive jQuery UI widget I propose:
- Add a feature specific to off-canvas dialogs that provides only horizontal resizability.
- Any calls to resizable() that only result in horizontal off-canvas reziability will be cancelled in favor of the the new off-canvas-specific feature.
- Calls to resizable() that expect something more that horizontal off-canvas resizability will trigger a deprecation warning.
This approach would provide a regression-free experience for all core dialog uses, and provide deprecation warnings for any (I think unlikely) scenarios of resizable dialogs being used beyond that in contrib/custom.
Comment #5
lauriiiComment #6
catch#4 seems like a good compromise to me - essentially keep the UI the same, but deprecate the API for removal. I don't have an opinion on resizing offcanvas dialogs personally.
For anything using resizable directly, we already have the contrib project here, https://www.drupal.org/project/jquery_ui_resizable
Comment #7
droplet commentedWhat is the shim in Drupal? Is it the common way or the Drupal way?
I don't think we able to make 100% 1:1 mapping shim. How do you handle bug reports? and when to retire these shims?
If #6 a simple module works, why do we provide shims for other jQuery UI? Doesn't a simple module a better way?
It's a big debt to the codebase.
Comment #8
lauriiiI brought this issue up in the previous UX meeting #3203260: Drupal Usability Meeting 2021-03-19. We discussed this issue but we didn't come to any conclusion. Something that came up is that the token browser is using resizable dialogs. The dialog is rendered on the right side so that both the form, and the dialog remain visible. This is implemented with a regular dialog likely because it's code that pre-dates off-canvas. This use case would likely provide better UX if converted to off-canvas.
Comment #9
gábor hojtsyDo we have a definite list of where resizable is used in core? The issue summary only mentions off-canvas, while #8 mentions token browser. Are there others we did not figure out yet?
If we would know how to detect the library use, we can also grep contrib for uses of that library. There is http://grep.xnddx.ru/ to do that. If it is the mention "resizable" in libraries.yml then the results are as follows: http://grep.xnddx.ru/search?text=resizable&filename=.libraries.yml
admincss 8.x-2.2 :: admincss.libraries.yml
behat_ui 4.0.0-alpha3 :: behat_ui.libraries.yml
better_messages 8.x-1.x-dev :: better_messages.libraries.yml
bootstrap 8.x-3.23 :: bootstrap.libraries.yml
chat_livehelperchat 8.x-1.2 :: chat_livehelperchat.libraries.yml
closedquestion 8.x-3.x-dev :: closedquestion.libraries.yml
erd 2.x-dev :: erd.libraries.yml
gridstack 8.x-2.5 :: gridstack.libraries.yml
hospital_management 8.x-1.x-dev :: web/themes/bootstrap/bootstrap.libraries.yml
paragraphs_previewer 8.x-1.5 :: paragraphs_previewer.libraries.yml
asset_injector 8.x-2.x-dev :: asset_injector.libraries.yml
easy_email 2.0.x-dev :: easy_email.libraries.yml
jquery_ui_dialog 8.x-1.x-dev :: jquery_ui_dialog.libraries.yml
jquery_ui_resizable 8.x-1.x-dev :: jquery_ui_resizable.libraries.yml
layout_builder_asset 8.x-1.x-dev :: layout_builder_asset.libraries.yml
micro_site 8.x-1.0-alpha6 :: micro_site.libraries.yml
Should we be grepping for derivative libraries of resizable as well or are these conclusive of the users of resizable then (assuming the grep site is extensive enough, which we usually do for the sake of similar decisions)?
Comment #10
gábor hojtsyChecking core uses, I could not figure out how to do that honestly. https://git.drupalcode.org/search?utf8=%E2%9C%93&search=.resizable%28&gr... only finds dialog and friends but which ones make use of the resizable feature is not clear.
Grepping for the library, core.libraries.yml directly provides it, but no other core library seems to depend on it. https://git.drupalcode.org/search?utf8=%E2%9C%93&search=jquery.ui.resiza...
So how do we know where it is used in core? (And which derivative we should check for for contrib?)
Comment #12
xjmComment #13
bnjmnmSomething that suggests many users are not aware that off-canvas dialogs are resizable: the Layout Builder Modal module. It's possible I'm misunderstanding this part of the module summary, bit it sounds like it was created primarily to provide more width to layout builder dialogs?
Comment #14
bnjmnmRe #10
Fortunately this is fairly easy to narrow down. jQuery UI dialog is not accessed directly, but via
drupal.dialog:library. This library includesmisc/dialog/dialog.position.js: {}which changes the dialog default settings to disabling resizable by default:Since this is the default, it's only necessary to find places where the default
autoResize trueis changed tofalse. This happens in two places:\Drupal\Core\Ajax\OpenOffCanvasDialogCommand::__construct, which includes$this->dialogOptions['autoResize'] = FALSE;core/modules/ckeditor/js/ckeditor.es6.jswhich includesSo dialogs triggered by CKEditor are resizable at these narrower viewport widths. Some things worth noting:
Comment #15
bnjmnmI grepped through contrib to find places where
autoResizewas set to something other than the default TRUE, which disables resize: http://grep.xnddx.ru/search?text=autoresize&filename=Just a quick review of those results provides a sense of what is likely needed:
autoResizebut explicitly disableresize, so these don't need resizabilityautoResize, which is expected as it was mentioned earlier that token uses resizable (and draggable) dialogsAside from the evidence that at least two popular modules use dialog for resizability, it also shows that there is contrib expectation for dialog draggability. These two features are heavily integrated with the
drupal.dialogAPI and its custom events. They're not easily swapped out with contrib-provided versions of jQuery UI resizable/draggable. It may be necessary to provide a legacy version ofdrupal.dialogthat continues to use jQuery UI assets, and can be used simultaneously with whatever dialog solution is added that doesn't use jQuery UI.Comment #16
bnjmnmUpdated proposal based on the prior two comments:
Drupal.dialog, not direct interaction with jQuery UI. If core loses draggability/resizability on dialogs, contrib modules requiring these features wouldn't be able to get them by simply adding the contrib modules for jQuery UI resizable, draggable, etcProposed solution for core
jquery.ui.resizableis already deprecatedProposed solution for contrib/custom
Drupal.dialog()withDrupal.jqDialog(), and dialogs will continue to work as expected.Drupal.dialogfeature that will no longer be available with the jQuery UI dialog replacement, and refer projects to jq_dialog as a way to continue use of this functionality. I.e. a console warning would be triggered for any dialogs withresizableordraggableset toTRUE. This would give projects sufficent time to add jq_dialog as a dependency, instead of being surprised by a dialog replacement that doesn't support dragging or resize.Comment #17
lauriiiI'm personally in favor of getting rid of the resizable functionality (potentially altogether, including the current usage), because I think it's just providing users a workaround around existing UX problems. The dialog should be opened large enough so that its content is usable. However, take that with a grain of salt because I'm not a product manager.
If we are going to get rid of jQuery UI resizable without providing similar feature in the dialog implementation, doesn't that mean we have to deprecate Drupal.dialog completely? We cannot change or remove public API in a minor release based on the current release policies.
Comment #18
catchWould be good to update the issue summary for where the usage is and isn't (in core and contrib).
Inclined to agree with @lauriii in #17.
I would think we'd need to trigger a deprecation if resize is used (if we can...), and then change the dialog API in Drupal 10?
Comment #19
lauriiiIt's tricky because the new dialog approach wouldn't support resize. Therefore, we would have to use jQuery UI dialog at least with resizable dialogs.
I discussed with @bnjmnm about possibly switching back to jQuery UI dialog when resizable is enabled. @bnjmnm pointed out that it might be tricky to do so, because the amount of flexibility the jQuery UI API provides, allows enabling resizable after the dialog has been initialized.
Based on that, I proposed an approach where we would add new option for selecting which of the dialogs should be used when a new dialog is initialized. We would make it default to jQuery UI and trigger deprecation warning when the default hasn't been overridden.
Comment #25
finnsky commentedHi everybody!
I added a proof of concept demonstrating https://interactjs.io/ for resizing.
We can add some arbitrary internal library for resize (and not only) that will work for attributes like “data-resize-element” or “data-resize-element=left”.
Before the patch, the resize does not look very good in offcanvas:
After the patch:
This library also supports drag and drop and much more. There also seems to be modularity. Could be a good alternative to the current resize implementation and could be an independent part to make it easier to redesign dialog boxes. MR is pretty rough but it definitely shows the benefits of this library.
Please review
Comment #26
finnsky commentedFor test enable Layout Builder module and enable it for article. Also Workspaces module.
Comment #28
finnsky commentedComment #29
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #30
needs-review-queue-bot commentedFalse positive
Comment #31
catchThe videos in #25 look pretty good. This could use a dependency evaluation. I assume the CDN imports would convert to bringing the library into core?
Also not clear to me how this interacts (or not) with #2158943: PP-1 Add a native dialog element using HTMX to deprecate the jQuery UI dialog.
Comment #32
finnsky commentedYes, it could be a good replacement but it seems that the library I suggested is no longer supported.
https://github.com/taye/interact.js
It is related in such a way that we also have to replace or remove
https://jqueryui.com/resizable/
Here is an option with replace