Configured a popup based on a block, with layout Bottom Right, no overlay, trigger=Automatic and 5s delay.

After 5 seconds the popup appears, but the contents are missing. All you see is a thin horizontal line because only the frame is being rendered, not the form that was configured in the region.

Looking at the code, it's because of this in simple_popup_blocks.js:

// Automatic trigger with delay
if (values.trigger_method == 0 && values.delay > 0) {
delays = values.delay * 1000
$('.' + modal_class).delay(delays).fadeIn('slow')
if (values.overlay == 1) {
setTimeout(stopTheScroll, delays)
}
}

The "fadeIn" line is only acting on the outer class and misses out the contents.
Adding the following line fixes the problem:

// Automatic trigger with delay
if (values.trigger_method == 0 && values.delay > 0) {
delays = values.delay * 1000
$('.' + modal_class).delay(delays).fadeIn('slow')
$(css_identity + block_id).delay(delays).fadeIn('slow') // Added
if (values.overlay == 1) {
setTimeout(stopTheScroll, delays)
}
}

The patched js file is attached.

Let me know if you need any further information.

Comments

opsdemon created an issue. See original summary.

opsdemon’s picture

Issue summary: View changes
opsdemon’s picture

Title: Popup content disappears when delay enabled » Popup contents disappears when delay enabled
s_leu’s picture

Status: Active » Needs review
StatusFileSize
new496 bytes

Can confirm that this is a problem with a popup configured to show automatically with a delay.

@opsdemon Thanks for providing the code to solve this and pointing this out. In order to streamline the committing of your code please consider to write a patch next time instead of uploading a zip file. This also helps reviewing and adding the patch in composer.json of installations that want to use the fix.

Adding a patch here:

stevenx’s picture

The Patch works. Thanks

  • mattbloomfield committed 4d62477 on 8.x-2.x
    Issue #3040744 by s_leu, opsdemon: Popup contents disappears when delay...
dantesinferno’s picture

Hey I'm using this module to build a custom popup with a custom form.

I've faced the same problem, the form content was not showing but the patch didn't work for me, because the form was being wrapped multiple times and all of the children with the "modal_class" variable were always with "display: none".

I'm not sure if it's just me but just in case someone get the same problem, I finally got it working by editing the code on line 63:

"$(css_identity + block_id)." before
"$(css_identity + block_id).once()." after

I think it happens sometimes when you have functions inside a behavior function the events are triggered more than once.

I'm not a drupal expert though but this module has saved me a lot of time, thanks.

  • mattbloomfield committed 310a4fd on 8.x-2.x
    Issue #3040744 by s_leu, dantesinferno, mattbloomfield: Popup contents...
mattbloomfield’s picture

Thank you, that change in #7 has been committed.

mattbloomfield’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

mellowtothemax’s picture

Patch #4 works for me too. It hasn't been committed in the latest version 8.x-2.8 however.

mefron’s picture

I noticed that this issue seemed to re-appear (I installed this module yesterday and found that delaying the popup caused led to an empty notification). The previously accepted patch no longer applies to the needed file, so I generated a new one. Perhaps it will help someone...I cant' recall how to upload a patch file, so I'm pasting the contents of my patchfile here:

--- js/simple_popup_blocks.js   2022-07-20 12:31:27.000000000 -0400
+++ js/simple_popup_blocks.js.fixed     2022-07-20 12:37:48.000000000 -0400
@@ -227,6 +227,7 @@
         if (values.trigger_method == 0 && values.delay > 0) {
           delays = values.delay * 1000
           $('.' + modal_class).delay(delays).fadeIn('slow')
+          $(css_identity + block_id).delay(delays).fadeIn('slow')
             if (values.overlay == 1) {
               setTimeout(stopTheScroll, delays)
             }
nataliajustice’s picture

The issue is appearing again. The solution of #13 is working fine. I have created a new patch to upload it to the issue

vasyok’s picture