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
Comment | File | Size | Author |
---|---|---|---|
#13 | error.png | 77.56 KB | ThomWilhelm |
#9 | after-3282241-9.png | 107.25 KB | Shyam_Bhatt |
#9 | before-3282241-9.png | 106.59 KB | Shyam_Bhatt |
Issue fork bootstrap-3282241
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
lpeabody CreditAttribution: lpeabody commentedI'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.
Comment #3
lpeabody CreditAttribution: lpeabody commentedI got this working. I had to attach the core/drupal.dialog.ajax library to the Twig template with the AJAX modal link.
After I added that, the modal rendered as expected every time.
Comment #4
anoopsingh92Hello @cprietom
Please try this, the dialog should be open on the page.
<a class="btn btn-info use-ajax" data-dialog-options="{"width":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:
Now the libraries are loaded on the page. Now you can attach your library to your specific page using the
or if you want to display it on all the pages then include your library name in the .info.yml file such as:
Modules
Themes
Comment #6
anoopsingh92Comment #8
anoopsingh92Hi,
I have fixed this modal popup issue and committed the changes.
Please review and merge this MR.
Comment #9
Shyam_Bhatt CreditAttribution: Shyam_Bhatt commentedI 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:
After:
Comment #10
Shyam_Bhatt CreditAttribution: Shyam_Bhatt commentedComment #12
shelaneComment #13
ThomWilhelm CreditAttribution: ThomWilhelm commentedThis 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.