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
| Comment | File | Size | Author |
|---|---|---|---|
| Screenshot from 2025-01-17 14-20-43.png | 299.32 KB | pivica |
Issue fork drupal-3500520
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
pivica commentedComment #3
pivica commentedComment #4
pivica commentedComment #5
pivica commentedComment #6
cilefen commentedIs 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?
Comment #7
pivica commentedComment #9
pivica commentedMR 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.
Comment #10
cilefen commentedUnderstood.
Comment #11
smustgrave commentedSo 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.
Comment #12
berdirIt looks like #3478087: Modernize Drupal.ajaxCommands.scrollTop() made this obsolete, but leaving open so we can test this in our project.