Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have problem with opening modal window from another modal window.
I have used such code for open window
<a href="/link" class="use-ajax btn-info btn" data-dialog-type="modal" data-drupal-link-system-path="link">{{ 'Name'|t }}</a>
Problem have appeared after update to 3.17
3.16 works fine
Notice:
everything works well when you try to open popup from page. Error appears only after opening another popup from first popup.
Correct markup:
Incorrect markup:
Comment | File | Size | Author |
---|---|---|---|
#27 | 3032922-27.patch | 606 bytes | longwave |
#20 | missed_wrapper_3_20-3032922-20.patch | 606 bytes | YahyaAlHamad |
#19 | missed_wrapper-3032922-19.patch | 643 bytes | YahyaAlHamad |
#18 | drupal-modal reopened.png | 103.64 KB | akalata |
#18 | drupal-modal after close.png | 212.11 KB | akalata |
Comments
Comment #2
alexdoma CreditAttribution: alexdoma at Drupal Teams commentedComment #3
markhalliwellI'm not entirely what you mean here, but the only commit that touched modals between those versions is the above related issue.
Comment #4
Anatoliy Vorobyov CreditAttribution: Anatoliy Vorobyov at FFW commentedEverything works as expected.
Drupal: 8.6.9;
Bootstrap: 3.17;
Click on "Launch demo modal" closes the current modal and opens up a new one.
Without data-dismiss="modal" you will see two modals opened.
But if you want only one modal to be opened than please check code below:
Comment #5
markhalliwellI don't think that's what the OP is referring to...
Comment #6
YahyaAlHamadI also too have this issue, after updating to bootstrap 3.14, the first time you open the layout, it opens as expected, after that, it gets stripped off the header and the body, and would look weird, apparently this causes the problem:
Comment #7
imclean CreditAttribution: imclean at Digital Ink commentedThe modal content, header and body wrappers aren't being generated when opening one modal from within another. One example is in the experimental Media Library module. This is a modal example only, I know Bootstrap doesn't directly support experimental modules.
Within a Media Library widget, click "Add media" you might see something like this (Large Modal):
Close the modal then click "Browse Media". In the "Browse Media" modal there's an "add media" link at the top. Click that and the following appears:
@alexdoma as provided screenshots showing an example of the missing markup. This was introduced in #2997347: Using $.fn.dialog duplicates content when it lives in DOM.
To confirm, remove the following lines from
modal.jquery.ui.bridge.js
:Removing that code alone may not be sufficient, or correct. The title of the second modal isn't generated properly in my case.
Comment #8
imclean CreditAttribution: imclean at Digital Ink commentedEmbedded screenshots in IS.
Comment #9
markhalliwellI'd like to hear back from the OP, @alexdoma
Comment #10
alexdoma CreditAttribution: alexdoma at Drupal Teams commented@markcarver
Sorry for the long reply.
I can confirm @yahyaalhamad and @imclean words.
I have removed this lines and popup works as expected. Html markup became correct.
Comment #11
YahyaAlHamadComment #12
markhalliwellSorry, but simply saying "removing this line works" doesn't really describe the actual issue at hand or what's going on. I'm going to need more details as to why removing said line "works" when this has already underwent numerous testing.
Comment #13
imclean CreditAttribution: imclean at Digital Ink commentedI did spend a bit of time narrowing it down as I missed comment #6 completely. It's returning early from
Dialog.ensureModalStructure()
if the the propertydata-drupal-theme="bootstrapModal"
is present. Presumably that property doesn't guarantee the structure is complete.For a lower level run down I'll need to spend a bit more time on it, but this will have to wait.
In terms of testing, it's a very specific case: clicking on a modal link within a modal to open another modal.
Comment #14
imclean CreditAttribution: imclean at Digital Ink commented@alexdoma do you have anything further you can add?
Comment #15
alexdoma CreditAttribution: alexdoma at Drupal Teams commented@imclean nothing new.
Like you wrote - it's a very specific case: clicking on a modal link within a modal to open another modal.
To solve this problem, I just froze the version - 3.16
Comment #16
imclean CreditAttribution: imclean at Digital Ink commentedComment #17
akalata CreditAttribution: akalata as a volunteer commentedI'm not sure if the cause of my issue is the same as OP, but the result seems to be the same.
Edited to add: Reverting back to 3.16 (from 3.19) does fix this issue.
Comment #18
akalata CreditAttribution: akalata as a volunteer commentedFollowing up to #12, on why removing
if ($element.is('[data-drupal-theme="bootstrapModal"]'))
works:div#drupal-modal
is appended to thebody
.div#drupal-modal
includes the attributedata-drupal-theme="bootstrapModal"
.div#drupal-modal
persists, but with class and element style changes which remove the modal from view. data-drupal-theme="bootstrapModal" remains on the element.if ($element.is('[data-drupal-theme="bootstrapModal"]'))
evaluates totrue
and the content of the modal is returned directly, without the additional bootstrapModal HTML wrappers.Comment #19
YahyaAlHamadAdding a patch to remove the convicted line of code temporarily, this is not a permanent solution. (For version 3.19)
Comment #20
YahyaAlHamadAlso for 3.20
Comment #21
crzech CreditAttribution: crzech as a volunteer commentedI've been experiencing the same issue, the only way to fix this without using the patch @YahyaAlHamad has published is to close modal Dialog that is currently open before opening a new one. This is what I've done on the ajax callback triggered by the button that I need to open the second modal:
Comment #22
Rajendar Reddy CreditAttribution: Rajendar Reddy commentedI am also facing same issue in 3.21 in the Layout Builder pages(D8.8.1+ Bootstrap + Bootstrap Layouts). Header and wrapper have been removed in the second modal after closing the first one and initiate the second one in the Layout section. #20 worked for me.
Comment #23
super_romeo CreditAttribution: super_romeo as a volunteer commented#20 doesn't worked for me.
/admin/appearance/settings/bootstrap Javascript / Modals / jQuery UI Dialog Bridge / Disable works for me.
Comment #24
markhalliwellDisabling is equivalent to bypassing; it's not a fix for this issue.
Comment #25
super_romeo CreditAttribution: super_romeo as a volunteer commentedYes. I know this is just a workaround. But it could be the hotfix for others.
Comment #26
super_romeo CreditAttribution: super_romeo as a volunteer commentedDear @markcarver, you might not be able to fix it for a fee?
I ready to pay, because this feature is important to me.
Comment #27
longwaveI am also experiencing this issue when opening a second modal from within an existing modal. Not marking "needs review" as I believe this is a workaround and not the real fix, but don't currently have time to investigate further.
Attached is #20 rerolled for 8.x-3.23.
Comment #28
igonzalez CreditAttribution: igonzalez commentedGood morning,
I'm using the latest version (8.x-3.23) and I have the same problem.
None of the solutions have worked for me.
Greetings and thanks