| @@ -717,8 +717,15 @@ | ||
| 717 | 717 | |
| 718 | 718 | const offCanvas = document.querySelector('." . esc_js($class_ID) . "'); |
| 719 | 719 | const overlay = document.querySelector('." . esc_js($overlay_ID) . "'); |
| 720 | 720 | |
| 721 | + // With no template picked the widget prints a placeholder instead of | |
| 722 | + // the panel markup, so these lookups come back empty. Bail out rather | |
| 723 | + // than throwing on insertBefore and losing the handlers below. | |
| 724 | + if (!offCanvas || !overlay) { | |
| 725 | + return; | |
| 726 | + } | |
| 727 | + | |
| 721 | 728 | // Moves all Popupes to right after the <body> opens |
| 722 | 729 | document.body.insertBefore(overlay, document.body.firstChild); |
| 723 | 730 | document.body.insertBefore(offCanvas, document.body.firstChild); |
| 724 | 731 | |