Problem/Motivation
If you have a jQuery UI dialog modal (a dialog having the modal configuration set to TRUE) and a Off canvas rendered at the same time (i.e. the dialog is opened via the Off canvas), the modal is repositioned incorrectly when resizing the window.
Here is an example using Layout Builder and the contrib. module Layout Builder Modal:

(thanks to kevinfunk for providing the GIF in #3074302)
The expected behaviour here would be that the modal keeps being centered on window resize.
You can also reproduce this behaviour in Drupal core:
<a href="/node/add/page" class="use-ajax" data-dialog-options='{"width": 500,"modal": true,"autoResize":true}' data-dialog-type="dialog">Dialog</a>
<a href="/node" class="use-ajax" data-dialog-renderer="off_canvas" data-dialog-type="dialog">Off canvas</a>
If you only would open the Dialog, it would resize and the position would be as expected. But if you first open the off canvas, and then the dialog the same behaviour as with Layout Builder Modal.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #39 | interdiff-37_39.txt | 652 bytes | gauravvvv |
| #39 | 3075236-39.patch | 6.52 KB | gauravvvv |
| #37 | interdiff_33-37.txt | 642 bytes | mrinalini9 |
| #37 | D-11-3075236-37.patch | 6.49 KB | mrinalini9 |
| #36 | 3075236-nr-bot.txt | 3.11 KB | needs-review-queue-bot |
Comments
Comment #2
johnwebdev commentedComment #3
johnwebdev commentedComment #4
johnwebdev commentedHere is a failing test. I'm thinking we should probably change the assertion just to ensure it's not repositioned on the top right corner on a resize instead of doing some guessing with where it's approximately is supposed to be using the left property. Nonetheless it's the start, and it shows the bug.
Comment #6
johnwebdev commentedTrying to debug and from what I can see is that Drupal.offCanvas.resetSize targets the dialog opened after the off canvas instead of the off canvas div. I'm not sure why that happens though.
It looks like the event listener stored does point to the correct element. For fun, I decided to remove the debounce() around the resize, and that seemed to resolve the issue.
Comment #7
johnwebdev commentedLet's see if test passes when removing the debounce() function.
Comment #9
johnwebdev commentedReworked the test a bit.
Comment #10
johnwebdev commented@group should still be dialog though :)
Comment #11
johnwebdev commentedAlthough this passes I believe we should look in to why this happens, and see if we can fix that. Removing the debounce would affect the performance.
Comment #12
johnwebdev commentedOkay, this brings back the debounce.
Comment #15
seanbReroll for Drupal 9.
Comment #16
raman.b commentedRe-rolling for 9.2.x
We also need to account for the 1px border added by
.ui-widget.ui-widget-contentComment #18
design.er commentedPatch #16 is working great for me on multiple projects with 9.1.5.
Thanks for taking care of that! :)
Comment #22
ranjith_kumar_k_u commentedComment #24
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #25
meanderix commentedThis patch is failing after changes made in #3350972: [random test failure] Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderUiTest::testReloadWithNoSections() (Drupal 9.5.9). Are these two patches fixing the same thing?
Here's the patch that I think went into core:
https://www.drupal.org/files/issues/2023-04-10/3350972-9.4_9.5-16.patch
Comment #27
ricovandevin commentedReroll
Comment #28
vlad.dancerComment #29
vlad.dancerPatch from #27 applies for 9.5.10. Thank you @ricovandevin.
Comment #30
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch 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 #31
seanbPatch in #27 failed to apply. Here is another attempt for a reroll of #22 for 9.5.10.
Comment #32
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch 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 #33
gauravvvv commentedI have re-rolled patch #31, for D11. Not adding interdiff as the patch doesn't applies anymore to d11.
Comment #34
gauravvvv commentedAdded patch for 9.5 along with interdiff with #31.
Comment #35
gauravvvv commentedWrong patch uploaded in #33, added the correct patch for d11.
Comment #36
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 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 #37
mrinalini9 commentedFixing custom command failure issues in #35, please review it.
Thanks & Regards,
Mrinalini
Comment #38
smustgrave commentedCC failure
Comment #39
gauravvvv commentedTried fixing CC failures, attached interdiff for same