Problem/Motivation

When the overlay dialog is open, it's hard to scroll without it jumping. Trying to get to the bottom and it keeps jumping to the top. Or vice versa.

Steps to reproduce

If you have a paragraph component with many fields, when you scroll down, the scroll position will jump back up. You have to fight it to get to the bottom.

I can post a screen recording if that doesn't make sense.

Proposed resolution

Seems to be stemming from this repositioning function in builder.js.
`lpDialogInterval = setInterval(repositionDialog.bind(null, lpDialogInterval), 500);`

For me, the solution is commenting that line out. When I do, the widget works as it should.

Conclusion

Since I'm the only posting this issue that I see, I'm concerned it's something particular to my installation, but as of now, I can't tell what that would be. Therefore, I'm not sure this is truly a proposed patch. Just something that alleviates my issue.

Is anyone else having this issue?

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

xpersonas created an issue. See original summary.

xpersonas’s picture

yospyn’s picture

I had this issue and the patch solved it for me! Using 2.0.0-beta9 on core 9.3.12 with bootstrap_layout_builder 2.0.1.

Because of the "jump", I wasn't able to select a column % in the overlay dialog (of a layout paragraph type). But now smooth scrolling.

sharique’s picture

Commenting code is not a good idea, it could be removed. Anyway, the solution works,

xpersonas’s picture

Commenting code is not a good idea, it could be removed.

Generally I agree, but commenting the code was a good idea for me at this point because:

  • I wasn't sure if this was an issue others were having or something particular to my installation/theme
  • I wasn't sure what functionality was being lost by doing this. I assume it's there for a reason, but from what i can tell, things seem to just work without it. I haven't dug much further yet.

I may propose an official patch now that I see a couple of others have the same issue.

anybody’s picture

Version: 2.0.0-beta9 » 2.0.x-dev

I think this is a topic which might better be solved upstream in core?

Core modals are not a thing Drupal should be proud of ... ;)

godotislate’s picture

I'm experiencing this as well on 2.0.1.

Couple notes:

breezeweb’s picture

I'll also confirm that this seems to be happening for me as well on 2.0.1

narendra.rajwar27’s picture

Status: Active » Needs review
StatusFileSize
new1.1 KB

Adding re-rolled patch for 2.0.x-dev, Creating js transpiled versions of the es6 js file showing lot more changes. Possibly due to npm version, so keeping it by manual updation in file.

Status: Needs review » Needs work

The last submitted patch, 9: 3276258-9.patch, failed testing. View results

heavystonehead’s picture

"Is anyone else having this issue?" Yes i have same issue
Patch #9 works for me (Drupal 9.4.8; PHP 8.1.11; Layout Paragraphs 2.0.1)

inversed’s picture

I've noticed that this does not happen on all my Layout Paragraph 2.x modals to the same degree. For me, it's worst on a modal that is fairly small to begin with (near screen height) and then expands (for example with collapsed or tabbed Field Groups). However for some others, like one that is quite long, the jump is minimal and only on maybe one of the Field Group tabs.

The patch in #9 apples cleanly for me on 2.0.1 and solves the problem. I think it's a heavy handed fix given that the repositioning of the modal is probably in there for a reason. But without it, I would be blocked without some sort of workaround.

tommasorandazzo’s picture

Confirmed #9 is working for me: PHP 7.4, Drupal 9.4.8

yospyn’s picture

Also confirming #9 worked for me: PHP 8.1.13, Drupal 9.4.8, and layout_paragraphs 2.0.1. Nice flow no stutter.

dasginganinja’s picture

The patch in #9 seemed to initially fix the jump stutter for us. It works well for the dialog that LP presents.

Context:
Drupal 9.4.8
Layout Paragraphs 2.0.1
Media Library
Admin Theme: Seven / Claro

I did discover an issue with this, and I'm sure it's related to the core modal since this exists both in Seven and Claro themes.

On node of bundle 'page' I have a field called `field_content_sections`, which is an Entity Reference Revision field pointing at paragraphs.
One of the paragraphs we reference, `document_listing`, has an entity reference field that points to Media - Document. We utilize the Media Library widget for the form display of this field.

When adding a document list paragraph via LP the dialog that LP creates resizes as expected. When I click to "Add Media" it pops open the core modal over the LP dialog. I can see the Insert buttons and can select media items. I can also see the button on the LP dialog to save.

After adding a file to the media overlay and clicking insert, the focus is returned to the LP dialog and a resize occurs. The action buttons are no longer visible at this point and have been resized out of the focus.

If you can't reproduce this, please try to zoom in or try on a smaller screen size to cause the LP dialog to overflow the visible screen size.

Good luck everyone. This is getting super close!

jonathanshaw’s picture

  $(window).on('dialog:aftercreate', function (event, dialog, $dialog) {
    if ($dialog[0].id.indexOf('lpb-dialog-') === 0) {
      clearInterval(lpDialogInterval);
      lpDialogInterval = setInterval(repositionDialog.bind(null, lpDialogInterval), 500);
    }
  });

Shouldn't we be removing this whole block of code? If we remove the line lpDialogInterval = setInterval(repositionDialog.bind(null, lpDialogInterval), 500); isn't all the rest of the above code pointless?

magtak’s picture

Facing the same issue. #9 seems to fix it.

cobadger’s picture

Assigned: Unassigned » cobadger
Status: Needs work » Active

While I agree that removing the setInterval call here:

lpDialogInterval = setInterval(repositionDialog.bind(null, lpDialogInterval), 500);

will correct the stuttering behavior, it doesn't address the need to reposition the dialog when its height changes (see https://www.drupal.org/project/layout_paragraphs/issues/3252978 and https://stackoverflow.com/questions/5456298/refresh-jquery-ui-dialog-pos...).

We had some logic that used to test for whether the dialog height had changed but that logic was removed in commit b95cccc3.

In a moment I'll add a patch that only repositions when the height of the dialog has changed (while maintaining the logic that handles multiple dialogs).

cobadger’s picture

Assigned: cobadger » Unassigned
Status: Active » Needs review
StatusFileSize
new2.87 KB

Patch attached.

Status: Needs review » Needs work
cobadger’s picture

Status: Needs work » Needs review
StatusFileSize
new2.86 KB

Updated my patch; revised patch attached.

magtak’s picture

#21 works much better than #9 for me - I can now scroll again

heavystonehead’s picture

If you use a media library and this overlay opens, i.e. via the paragraph overlay (or replaces it), then it will not be re-aligned in size and you cannot scroll. I don't know if that plays a role here at the moment. For me the overlay is too big after adding the image.

greenskin’s picture

Status: Needs review » Needs work

#21 does stop the jumping back to the top on scroll, but it doesn't keep the modal within the viewport. So the issue with #21 is on long pages with the edit dialog open, one could lose where the dialog is open/visible if they scroll too far above or below it.

greenskin’s picture

Status: Needs work » Needs review

Found the problem for my particular issue. My issue was resolved by setting the configuration on /admin/config/content/layout_paragraphs/modal-settings. Specifically I set: width to 90%; height to auto; and checked the "Modal autoresize" option.

naveenvalecha’s picture

We are using #21 for a long time on few big customer websites and its working fine for us

naveenvalecha’s picture

Here's the patch attached of the current PR against the latest 2.0.x

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

sethhill’s picture

Status: Needs review » Fixed

sethhill’s picture

Status: Fixed » Closed (fixed)