Problem/Motivation

The first time a modal is opened with a link like this:
<a href="/node/13" class="btn btn-info use-ajax" data-dialog-type="modal">Open modal</a>
the overlay is on top of the modal. Therefore, the "X" button is not clickable. The only way to close it is by pressing the "Esc" key. After closing the modal by pressing "X" and reopening the modal, the problem dissapears.

Steps to reproduce

Open any drupal node using a link like this: <a href="/node/13" class="btn btn-info use-ajax" data-dialog-type="modal">Open modal</a>
Using a different theme (like "Batik"), the modal works as expected.

Proposed resolution

Checking the difference in the divs's attributes when it works and when it does not, I've noticed that the first time the modal is opened the z-index is NOT being assigned neither to the <div... role="dialog"> nor to the <div class="class="ui-widget-overlay ui-front"></div>. Next times, both divs have z-index assigned: <div class="class="ui-widget-overlay ui-front" style="z-index: 100;"></div> and a <div... role="dialog" ... style="z-index: 101">
I don't know how, but it should be fixed to assign those values the first time the modal is opened.

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork bootstrap-3282241

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

cprietom created an issue. See original summary.

lpeabody’s picture

I'm experiencing this issue as well. When I open the modal the first time, the background is atop the modal and nothing is clickable, you have to press ESC to dismiss the dialog. Clicking the link again to trigger the modal dialog the z-index's are now set as expected and everything looks normal.

However, I am not using Bootstrap at all, so I think this is a Drupal core bug.

lpeabody’s picture

I got this working. I had to attach the core/drupal.dialog.ajax library to the Twig template with the AJAX modal link.

{{ attach_library('core/drupal.dialog.ajax') }}

After I added that, the modal rendered as expected every time.

anoopsingh92’s picture

Status: Active » Needs review

Hello @cprietom

Please try this, the dialog should be open on the page.

<a class="btn btn-info use-ajax" data-dialog-options="{&quot;width&quot;:400}" data-dialog-type="modal" href="/node/13">Open modal</a>

First of all, You can load dependencies of dialog in your themes libraries.yml or custom module libraries.yml such as:

my-module/my-module.libraries.yml
my_theme/my_theme.libraries.yml

my_library:
    css:
        theme: css/example.css {}
    js:
        js/example.js: {}
    dependencies:
        - core/drupal.dialog.ajax

Now the libraries are loaded on the page. Now you can attach your library to your specific page using the

{{ attach_library(my_module/my_library’) }}

or if you want to display it on all the pages then include your library name in the .info.yml file such as:

my-module/my-module.info.yml
my_theme/my_theme.info.yml

Modules

libraries:
  - my-module/my_library

Themes

libraries:
  - my_theme/my_library

anoopsingh92’s picture

Assigned: Unassigned » anoopsingh92

anoopsingh92’s picture

Assigned: anoopsingh92 » Unassigned

Hi,

I have fixed this modal popup issue and committed the changes.
Please review and merge this MR.

Shyam_Bhatt’s picture

Assigned: Unassigned » Shyam_Bhatt
FileSize
106.59 KB
107.25 KB

I have checked the MR !19 (https://git.drupalcode.org/issue/bootstrap-3282241/-/tree/3282241-bootst...)
After I added that, the modal rendered as expected every time. Please check the Testing images.

Before:
before-3282241-9

After:
after-3282241-9

Shyam_Bhatt’s picture

Assigned: Shyam_Bhatt » Unassigned
Status: Needs review » Reviewed & tested by the community

  • shelane committed 97fac956 on 8.x-3.x authored by lpeabody
    Issue #3282241 by anoopsingh92, Shyam_Bhatt, lpeabody, cprietom: Overlay...
shelane’s picture

Status: Reviewed & tested by the community » Fixed
ThomWilhelm’s picture

FileSize
77.56 KB

This change starting throwing Javascript errors on my site which in turn broke the antibot module which relies on Javascript working.

I've uploaded the errors I'm getting incase others have the same issues. Needed to roll back to 3.25 for now.

Status: Fixed » Closed (fixed)

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