If a popup's content is too large for the popup's window (container), 3 main issues come up:
- Content will be cut off and there's no way to scroll to see what's been cut off.
- Sometimes the popup initially displays with the bottom of the content showing only (not the top).
- With the upcoming forced focus code change, if there's a focusable element such as a link at the very bottom of the popup, then focus will be on that bottom link. Again, the top content will be out of view with no way to scroll to it.
Original post: https://wordpress.org/support/topic/pop-up-close-button-appears-out-of-the-screen/
- First add this CSS.
/* Possible fix for top of popup getting cut off. */
@media (max-width: 1023px) {
#popmake-123 { /* Targets a specific element. */
top: 5% !important;
overflow-y: scroll !important; /* Enable a vertical scrollbar if needed. */
height: 85vh;
}
}
Remove the media query if you want to apply this CSS for all devices.
-
Install the jQuery code in this gist via the PHP hook. This is preferred. There's a pure JavaScript snippet, but that was for a specific case.
-
To account for the forced focus code update, this kind of override logic (below) needs to go into the core plugin codebase.
var container = currentModal.find( ' .pum-container' );
var content = currentModal.find ( '.pum-content.popmake-content' );
// If the content overflows the container, then
// focus on the content to avoid focusing on something
// like a link at the very bottom. We also need to srcoll
// to the top of the content.
if ( content.height() > container.height() ) {
content.focus();
container.scrollTop(0);
return;
}
Screen capture of a popup where the content is bigger than the popup window. With the forced focus code update, you can see the first focus is on the link at the very bottom of the popup.