Modal blocks half of file input

Created on 7 March 2025, about 2 months ago

Problem/Motivation

When you use the 'Add media' button to open the media library in a module, the input to upload a file is focussed. This scrolls that element to the top of the modal, but the label and half the file input are covered by the modal title bar.

I've tested this on Claro and Gin and a custom (non-admin) theme on both Firefox and Chrome and I get the same results each time.

See screenshot:

Steps to reproduce

Set a media field to use the media library formatter
Choose 'Add media' on a media field.
Check that the file input gets selected and is slightly obscured by the modal title

Proposed resolution

I'm not sure of the resolution. I think something like adding scroll-margin-block-start as an inline style when the ajax is called might solve it.

Remaining tasks

Figure out an approach, implement it.

User interface changes

None

Introduced terminology

None

API changes

None

Data model changes

None

Release notes snippet

None

🐛 Bug report
Status

Active

Version

11.1 🔥

Component

CSS

Created by

🇮🇪Ireland markconroy

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @markconroy
  • First commit to issue fork.
  • Pipeline finished with Failed
    about 2 months ago
    Total: 88s
    #443365
  • 🇺🇸United States smustgrave

    Please check the pipeline before review.

    Also this seems like a CSS bug no?

  • 🇧🇷Brazil julio_retkwa Balneário Camboriú

    I've updated the JS removing forEach and making sure it scrolls just the modal (on my vanilla setup it was scrolling the document root too)

    Drupal.behaviors.mediaLibraryScrollOnOpen = {
        attach: function (context, settings) {
          const input = once('mediaLibraryScrollOnOpen', 'input[type="file"]', context)[0];
          if (input) {
            const modalContent = input.closest('#drupal-modal');
            if (modalContent) {
              setTimeout(() => {
                modalContent.scrollTo({
                  top: modalContent.offsetTop  - modalContent.scrollTop,
                  behavior: 'smooth',
                });
              }, 100);
            }
          }
        }
      };
    

    As I've investigated, the issue lies on jQuery adding max-height on #drupal-modal.ui-front ui-dialog-content ui-widget-content when it actually should add this property to .media-library-wrapper I couldn't find yet how we can tweak the jQuery

    If anyone could Shed a light I'll be thankful :)

  • Pipeline finished with Failed
    about 1 month ago
    Total: 191s
    #449618
  • 🇧🇷Brazil julio_retkwa Balneário Camboriú
  • Pipeline finished with Failed
    about 1 month ago
    Total: 1161s
    #449640
  • Pipeline finished with Failed
    about 1 month ago
    Total: 1262s
    #455645
  • Pipeline finished with Success
    about 1 month ago
    Total: 948s
    #455668
  • 🇧🇷Brazil julio_retkwa Balneário Camboriú
  • 🇧🇷Brazil julio_retkwa Balneário Camboriú
  • 🇮🇳India snehal-chibde

    hello, I have checked this issue on Drupal 11, in Claro and Gin theme. I am able to replicate it.
    Tested the MR , and the issue get resolved ie able to see the file input on click of Add media field in a content type, the popup gets opened and the scroll is up at the top of the modal. In terms of UX, may be this can still be improved, but it is fixing the issue of file input getting cut off.

    I have added before and after screenshots for reference.

Production build 0.71.5 2024