Problem/Motivation

In entity_browser.modal.js we are using next code to calculate modal height:

var vHeight = $(window).height();

This works fine for desktop but on mobile, it can return smaller height than the actual visual height because mobile browsers can show/hide browser bar and bottom bottom UI controls. This is especially visible on iOS, here is a screenshot on iPhoneX simulator with and without hidden UI:

With top and bottom UI elements:

Without top and bottom UI elements:

We can see a lot of wasted space.

Proposed resolution

As explained in https://stackoverflow.com/a/31655549 there are libraries that can help us with it but as a simple solution using window.innerHeight will return visual viewport height.

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

Here is a patch and a screenshot of how it looks now without browser UI elements:

This also works fine when UI elements are shown, the event is fired and a modal dialog will resize itself.

pivica’s picture

Status: Active » Needs review

Notice here with the usage of window.innerHeight and window.innerWidth will include the area covered by scrollbars, however, this is not a problem for us because we are applying overflow hidden to the body when showing EB modal dialog.

pivica’s picture

Issue summary: View changes

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

benstallings’s picture

Status: Needs review » Reviewed & tested by the community

Claude Code says:

Assessment — Good to merge:

- Removes two temporary variables (wWidth, vHeight) that were only used once each — cleaner.
- Removes two jQuery calls in favor of native browser APIs — marginally more performant and one fewer jQuery dependency in a hot resize/reflow path.
- The behavioral difference (scrollbar width, typically ~15-17px) is small but technically more correct for modal positioning.
- No risk of compatibility issues — window.innerWidth/innerHeight are supported in all browsers the module targets.

Clean, correct, no concerns.

anybody’s picture

Status: Reviewed & tested by the community » Fixed

Thank you! Merged!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.