Can't open pop up or new tab and display generate html

Code and example running here https://huggingface.co/spaces/TheDrakosfire/StoreGenerator

I’ve got a container running flask hosting an html file, scripts, css.
Locally, when I click my button to open a new tab with specific isolated html from the main page, it works perfectly. This also works for a pop up that goes straight to printing as pdf, or creating a pdf to download.

Once deployed to Spaces, this creates blank pages. This seems like a security response to prevent pop ups.

ASK: Is this a security measure? Is there a way to grant permissions?
ASK: Is there another way to accomplish this goal?


    window.printPageContainer = function() {
        var pageContainer = document.getElementById('brewRenderer');
            
            htmlContent = `
                <!DOCTYPE html>
                <html lang="en">
                <head>
                    <meta charset="UTF-8">
                    <meta name="viewport" content="width=device-width, initial-scale=1.0">
                    <link href="./dependencies/all.css" rel="stylesheet">
                    <link href="./dependencies/css.css?family=Open+Sans:400,300,600,700" rel="stylesheet" type="text/css">
                    <link href="./dependencies/bundle.css" rel="stylesheet">
                    <link href="./dependencies/style.css" rel="stylesheet">
                    <link href="./dependencies/5ePHBstyle.css" rel="stylesheet">
                    <link href="./storeUI.css" rel="stylesheet">  
                    <title>Print Preview - DnD Stat Block</title>
                    <link rel="stylesheet" href="styles.css">
                    <style>
                        @media print {
                            
                            .page {
                                page-break-before: auto;
                                page-break-after: avoid;
                                page-break-inside: avoid;
                                
                            }
                            .columnWrapper {
                                overflow: visible;
                            }
                            
                        }
                    </style>
                </head>
                <body>
                    ${pageContainer.innerHTML}
                </body>
                </html>
            `;
            // Open a new tab
        const newTab = window.open('', '_blank');

        // Check if the new tab was blocked
        if (newTab) {
            // Write the HTML content to the new tab
            newTab.document.open();
            newTab.document.write(htmlContent);
            newTab.document.close();
        } else {
            console.error('Failed to open a new tab. It may have been blocked by the browser.');
        }
    };