Problem/Motivation

We have a case where we use Entity Browser modal dialog with a bit of custom CSS for scrolling which makes the view itself scrollable and not the whole EB modal dialog content. We do this so upper tabs and bottom actions are always visible in modal dialog.

With this customizations when user clicks on view pager links next JS errors happens:

This happens because code will never enter while loop (because view scrollTop() is already not null) and scrollTarget element will point to DOM element and not jQuery object - then scrollTarget.get(0) will fail.

Steps to reproduce

Add next CSS code which will change scroll behavior of EB modal dialog and make EB view scrollable and not modal content, for example:

form.entity-browser-form {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

form.entity-browser-form .view,
form.entity-browser-form #ief-dropzone-upload {
  flex: 1 1 auto;
  overflow-x: hidden;
}

Then click on the view pager link in modal dialog and you will see exception in browser console.

Tested this with Drupal 10.4 but the JS code in 11.x is the same so problem is identical there.

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
Screenshot from 2025-01-17 14-20-43.png299.32 KBpivica

Issue fork drupal-3500520

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

pivica created an issue. See original summary.

pivica’s picture

Issue summary: View changes
pivica’s picture

Issue summary: View changes
pivica’s picture

Issue summary: View changes
pivica’s picture

Version: 10.4.x-dev » 11.1.x-dev
Issue summary: View changes
cilefen’s picture

Is this something that can or should be fixed in Drupal Core or is it more of an Entity Browser bug that we should move to that project?

pivica’s picture

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

pivica’s picture

Status: Active » Needs review

MR is ready for a check, and a fix is quite simple because I just optimized initialization and usage of scrollTarget and just made sure it is always a jQuery object no matter of code path execution.

> Is this something that can or should be fixed in Drupal Core or is it more of an Entity Browser bug that we should move to that project?

@cilefen I think the actual problem is in Drupal.AjaxCommands.scrollTop which does not properly initialize scrollTarget variable for all edge cases.

cilefen’s picture

Understood.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs title update, +Needs issue summary update

So reading the title first thought was this sounds like entity browser bug. But if it's not, per #9 then title should reflect the core bug

Issue summary appears to be incomplete

For core may need test coverage, if possible.

berdir’s picture

It looks like #3478087: Modernize Drupal.ajaxCommands.scrollTop() made this obsolete, but leaving open so we can test this in our project.

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.