Problem/Motivation

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

Issue fork drupal-3201835

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:

Comments

bnjmnm created an issue. See original summary.

bnjmnm’s picture

Title: Replacing(?) jQuery UI resize » Replacing(?) jQuery UI resizable
Issue summary: View changes
nod_’s picture

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.

bnjmnm’s picture

I 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.

lauriii’s picture

catch’s picture

#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

droplet’s picture

What 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.

lauriii’s picture

I 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.

gábor hojtsy’s picture

Do 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)?

gábor hojtsy’s picture

Checking 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?)

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

bnjmnm’s picture

Something 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?

The interface for the user to write content within this custom block would be through the off-canvas dialog which is the standard solution selected by the Layout Builder developers. The off-canvas dialog is very narrow and not an optimal user experience for this scenario, so to provide the author with a better interface this module let’s you use a modal dialog instead.
bnjmnm’s picture

StatusFileSize
new102.11 KB
new298.55 KB
new126.56 KB

Re #10

So how do we know where it is used in core?

Fortunately this is fairly easy to narrow down. jQuery UI dialog is not accessed directly, but via drupal.dialog: library. This library includes
misc/dialog/dialog.position.js: {} which changes the dialog default settings to disabling resizable by default:

// autoResize option will turn off resizable and draggable.
  drupalSettings.dialog = $.extend(
    { autoResize: true, maxHeight: '95%' },
    drupalSettings.dialog,
  );

Since this is the default, it's only necessary to find places where the defaultautoResize true is changed to false. This happens in two places:

  1. Off-canvas. The setting is overridden in off-canvas dialogs inside
    \Drupal\Core\Ajax\OpenOffCanvasDialogCommand::__construct, which includes
    $this->dialogOptions['autoResize'] = FALSE;
  2. Dialogs used by CKEditor when the viewport is under 600px. see core/modules/ckeditor/js/ckeditor.es6.js which includes
    dialogSettings.autoResize =
            window.matchMedia('(min-width: 600px)').matches;

So dialogs triggered by CKEditor are resizable at these narrower viewport widths. Some things worth noting:

  • CKEditor 5 will use dialogs provided by the CKEditor 5 library, no Drupal dialogs used
  • When used with Seven, it resizes the content area, but not the title bar or button pane. I could not find an issue for this, which does not surprise me. At these narrower widths, a user is most likely on a touch device and would not think to drag to resize a dialog, nor do I think they'd have a need to make it smaller
  • In Claro, resizing a (not off-canvas) dialog makes it flat-out vanish at any viewport width. So resizing definitely doesn't work for those core CKEditor uses right now. though it's There is an issue for this: #3186463: Dialog resize issue, and all of the examples are with non-core uses such as the token browser.
  • Dialog resizing works for these CKEditor dialogs in Stark/Stable, so it's possible there are users enjoying this feature on themes that aren't Seven or Claro. It doesn't look that great of a user experience as the form elements don't resize, and I still think it's unlikely that a mobile user would try to reduce the width of a dialog, but theoretically there could be users that use this feature.
bnjmnm’s picture

I grepped through contrib to find places where autoResize was 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:

  • Paragraphs and Entity Browser disables autoResize but explicitly disable resize, so these don't need resizability
  • Token disables autoResize, which is expected as it was mentioned earlier that token uses resizable (and draggable) dialogs
  • The Paragraphs Previewer module appears to be used by a nontrivial amount of sites, and this has resizable dialogs.

Aside 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.dialog API 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 of drupal.dialog that continues to use jQuery UI assets, and can be used simultaneously with whatever dialog solution is added that doesn't use jQuery UI.

bnjmnm’s picture

Updated proposal based on the prior two comments:

  1. #14 confirmed that core only uses resizable dialogs in Off Canvas and CKEditor 4 dialogs when the width is under 600px
  2. #15 established that it's not uncommon for contrib to enable resize on dialogs. It was also clear that other not-used-by-core jQuery UI dialog features such as draggable are used, and they're used via 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, etc

Proposed solution for core

  • The jquery.ui.resizable is already deprecated
  • Off Canvas dialogs will stop using resizable and we will add custom resizability (unless a good library has become available since my last search... not too many options unless we use Vue/React).
  • The other core use of resizable - CKEditor dialogs in <600px viewports - will be left as-is as the entire module will soon be deprecated

Proposed solution for contrib/custom

  • A jq_dialog module that provides the jQuery-UI-using Drupal.dialog. That can be used simultaneously with Drupal core's eventual non-Jquery-UI-dialog. Modules should be able to add jq_dialog as a dependency, then find/replace uses of Drupal.dialog() with Drupal.jqDialog(), and dialogs will continue to work as expected.
  • Ideally, I'd like to provide console warnings before #2158943: PP-1 Add a native dialog element using HTMX to deprecate the jQuery UI dialog lands. The warnings would triggered for any Drupal.dialog feature 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 with resizable or draggable set to TRUE. 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.
lauriii’s picture

I'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.

catch’s picture

Would 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.

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?

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?

lauriii’s picture

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?

It'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.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

finnsky made their first commit to this issue’s fork.

finnsky’s picture

Status: Active » Needs review
Issue tags: -JavaScript +JavaScript
StatusFileSize
new2.99 MB
new4.88 MB

Hi 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:

before

After the patch:

after

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

finnsky’s picture

For test enable Layout Builder module and enable it for article. Also Workspaces module.

finnsky’s picture

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new1.2 KB

The 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.

needs-review-queue-bot’s picture

Status: Needs work » Needs review

False positive

catch’s picture

Status: Needs review » Needs work
Issue tags: +Needs frontend framework manager review

The 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.

finnsky’s picture

Yes, it could be a good replacement but it seems that the library I suggested is no longer supported.
https://github.com/taye/interact.js

Also not clear to me how this interacts (or not) with (dialog)

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

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.