Radix UI Dialog Overlay disappears when switching browser tabs (Next.js + ShadCN)

I’m using Radix UI Dialog (via ShadCN UI) in my Next.js 13+ project.
Everything works fine when I open the dialog — the overlay (bg-black/80) appears as expected and blocks the background.

However, if I switch browser tabs (or minimize the Chrome window) and then return to the tab again,
the black overlay disappears, but the dialog content stays visible and interactive.
So it looks like the dialog is floating on the screen without any dimmed background.

This only happens after tab focus changes — not when opening or closing normally.

and i use it like this

<Dialog open={open} onOpenChange={setOpen}>
  <DialogTrigger asChild>
    <button onClick={() => setOpen(true)}>Open Dialog</button>
  </DialogTrigger>
  <DialogContent>
    <p>Dialog content here</p>
  </DialogContent>
</Dialog>

and my dialog.tsx is like this

"use client"

import * as React from "react"
import * as DialogPrimitive from "@radix-ui/react-dialog"
import { X } from "lucide-react"
import { cn } from "@/lib/utils"

const Dialog = ({ children, ...props }: React.ComponentPropsWithoutRef<typeof DialogPrimitive.Root>) => (
  <DialogPrimitive.Root {...props}>{children}</DialogPrimitive.Root>
)

const DialogTrigger = DialogPrimitive.Trigger
const DialogPortal = DialogPrimitive.Portal
const DialogOverlay = React.forwardRef<
  React.ElementRef<typeof DialogPrimitive.Overlay>,
  React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
>(({ className, ...props }, ref) => (
  <DialogPrimitive.Overlay
    ref={ref}
    className={cn(
      "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out",
      className
    )}
    {...props}
  />
))
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName

const DialogContent = React.forwardRef<
  React.ElementRef<typeof DialogPrimitive.Content>,
  React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
>(({ className, children, ...props }, ref) => (
  <DialogPortal>
    <DialogOverlay />
    <DialogPrimitive.Content
      ref={ref}
      className={cn(
        "fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 border bg-background p-6 sm:rounded-lg shadow-lg",
        className
      )}
      {...props}
    >
      {children}
      <DialogPrimitive.Close className="absolute right-4 top-4">
        <X className="h-4 w-4" />
      </DialogPrimitive.Close>
    </DialogPrimitive.Content>
  </DialogPortal>
))
DialogContent.displayName = DialogPrimitive.Content.displayName

export { Dialog, DialogTrigger, DialogContent }

and when i try to close the dialog whose overlay is already removed then it show me this error

Error: Failed to execute ‘removeChild’ on ‘Node’: The node to be
removed is not a child of this node.

Hamburger menu opens but links are not clickable and background darkens [closed]

I’m building a responsive navigation menu for my website. The hamburger menu opens correctly and darkens the background, but I can’t click on any of the links inside the menu. Clicking anywhere outside closes it. It’s live at http://testingpf.great-site.net/

enter image description here

I tried changing CSS and JavaScript. I worked a lot but still couldn’t find error and fix it.

Expected: I should be able to click the links when the menu is open.

Actual: Menu opens but links are not clickable; only closes when I click outside.

What am I missing? Is this a z-index or layering issue?

const toggle = document.getElementById('navToggle');
const nav = document.querySelector('.main-nav');
const overlay = document.createElement('div');
overlay.className = 'nav-overlay';
document.body.appendChild(overlay);

toggle.addEventListener('click', () => {
  nav.classList.toggle('nav-open');
  overlay.classList.toggle('active');
});
overlay.addEventListener('click', () => {
  nav.classList.remove('nav-open');
  overlay.classList.remove('active');
});
.main-nav {
  position: fixed;
  top: 0; right: -100%;
  width: 320px; height: 100vh;
  background: #fff;
  transition: right 0.3s ease;
  z-index: 1000;
}

.main-nav.nav-open { right: 0; }

.nav-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(11,42,74,0.5);
  z-index: 999;
  display: none;
}

.nav-overlay.active { display: block; }
<header class="site-header">
  <div class="container header-inner">
    <a class="brand" href="/">
      <img src="assets/img/profile.jpg" alt="Zohaib Ashraf Noori" class="brand-photo">
      <div class="brand-text">
        <h1>Zohaib Ashraf Noori</h1>
        <p class="muted">Accounting • Islamiat • Pakistan Studies</p>
      </div>
    </a>

    <nav class="main-nav">
      <a href="/" class="active">Home</a>
      <a href="/about">About</a>
      <a href="/notes">Notes</a>
      <a href="/classes" class="cta">Classes</a>
    </nav>

    <button class="nav-toggle" id="navToggle">☰</button>
  </div>
</header>

Why does Vite automatically insert tags for images and how can I disable or control it?

I’m using Vite + React with both SSR and SPA builds.
When I run the dev server or build for production, Vite automatically injects image preload tags like this:

<div id="root">
  <link rel="preload" as="image" href="/images/geonix-logo.svg">
  <div>...</div>
</div>

I never manually added these preload links anywhere in my code (not in index.html, not in React components).

What I checked:

  • These tags are not in index.html.

  • They are not imported or rendered manually in any components.

  • I searched the entire codebase for image preload links (<link rel="preload" as="image">), but couldn’t find any in the source. They only appear in the build output.

    • he same happens in both dev and production builds.

    • It occurs consistently with any image used in React components.

      .⚡ Temporary workaround I tried

      As a temporary fix, at the stage of sending the final SSR HTML,
      I extract these image preload tags from inside the root, remove them, and then insert them manually into the <head> before sending the response.

      This works but doesn’t feel like the best solution.

      My Vite config

      import { defineConfig, loadEnv } from "vite";
      import react from "@vitejs/plugin-react-swc";
      import path from "node:path";
      import { getProxyOptions } from "./server/proxy/getProxyOptions.js";
      
      export default defineConfig(({ mode, isSsrBuild }) => {
        const isDev = mode === "development";
        const isSpa = process.env.SPA === "true";
      
        const env = loadEnv(mode, process.cwd(), "REACT_APP_");
        const defineEnv = Object.entries(env).reduce((acc, [key, val]) => {
          acc[`process.env.${key}`] = JSON.stringify(val);
          return acc;
        }, {});
        const proxyOption = getProxyOptions(env);
      
        return {
          root: isSpa ? path.resolve(__dirname, "spaRoot") : path.resolve(__dirname, "."),
          plugins: [react()],
          publicDir: path.resolve(__dirname, "public"),
          define: defineEnv,
          build: {
            minify: "esbuild",
            sourcemap: false,
            cssMinify: true,
            copyPublicDir: !isSsrBuild,
            rollupOptions: { output: { manualChunks: undefined } },
          },
          ssr: isDev ? {} : {
            noExternal: [/^@forproxyband/main-ui-kit/, "classnames", "lodash", "uuid"],
          },
          server: {
            proxy: proxyOption && isDev ? { "/api": proxyOption } : undefined,
          },
          resolve: {
            alias: {
              "@": path.resolve(__dirname, "src"),
              "/src": path.resolve(__dirname, "src"),
            },
          },
        };
      });
      
      

      My questions

      1. Where exactly do these image preload tags come from in Vite’s runtime?

      2. How can I disable or control this behavior (e.g. disable image preloads or move them to the <head>)?

      3. Why are they inserted inside the #root element instead of the <head>?

Image won’t display in jsp page if inside tags

I have this block of code in a jsp page:

<script type="application/javascript">
    $(document).ready(function () {
        $('a.hide').click(function(e){
            e.preventDefault();
            if ($(this).parents('.arrears-notification').length) {
                $('.arrears-notification').hide();
            }
        });
    });
</script>

<div class="arrears-notification">
    <div style="display:flex;align-items:center;">
        <div class="col-md-12">&nbsp;</div>
    </div>
    <div style="display:flex;align-items:center;">
        <div>&nbsp;</div>
        <div style="border:2px solid #BEBEBE;border-radius:5px;padding:10px;margin: 0 auto;width:95%">
            <img src="https://link/to/image1.svg" style="width:24px;height:24px;">
            <c:out value='<b>Your ${ account.entries[0].accountType } is at risk.</b> Make a card payment now to keep your account active.&nbsp;<a href="/payment/payment.form" id="lnkPremium_Arrears">Clear your arrears.</a>' escapeXml="false" />
            <a class="hide" href="#"><img src="https://link/to/image2.svg" style="width:24px;height:24px;float:right;"></a>
        </div>
        <div>&nbsp;</div>
    </div>
    <div style="display:flex;align-items:center;">
        <div class="col-md-12">&nbsp;</div>
    </div>
</div>

If image2 is clicked, the entire div block should be hidden. This works when I paste the code into https://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_editor. However, when I run my application, image2 doesn’t display. It does display if I remove the <a> tags surrounding <img src="https://link/to/image2.svg" style="width:24px;height:24px;float:right;">. What’s wrong here and how do I get this to display in my jsp?

Is getImageData() broken in Javascript, and what can I do to fix it?

The getImageData() function for the Canvas appears to have ceased to work. As in, the program doesn’t recognise it as a function call.
Here’s the code I’ve been working on:

<canvas id="myCanvas"></canvas>
<img id="myImage" src="image.png" hidden="true" onload="
    let canv = document.getElementById('myCanvas');
    let cnxt = canv.getContext('2d');
    let img = document.getElementById('myImage');
    cnxt.drawImage(img,0,0);
        //    up to here it works fine; the problem is with the next line
    let imgData = cnxt.getImageData(0,0,canv.width,canv.height);
    alert(imgData.data.length);
        //    no alert happens; the command to .getImageData() halts the program
" />

I’m using Google Chrome on Windows, but the same thing happens when I use Microsoft Edge. I’m hosting locally on Xampp and yes, the images are stored in the same folder as the html page. I have tried specifying crossOrigin="anonymous" in the <img> tag, as well as permutations with different capitalization of the words; this causes drawImage() to cease to function as well.

What’s really strange is that when I open projects I wrote a few months ago, which also depend on getImageData() and were working fine then, they too have ceased to function.

What’s going on and what can I do?

Converting React native component into html

I want to use the react-native-html-to-pdf module to create a pdf out of my react-native-gifted-charts components.

Image of a LineChart

Example of the line chart code below

<LineChart 
  hideRules
  data={lineData}
  color={colors.text} 
  height={verticalScale(300)}
  textColor={colors.fieldText}
  xAxisLength={width - horizontalScale(90)}
  spacing={horizontalScale(23)}
  xAxisColor={colors.fieldText}
  yAxisColor={colors.fieldText}
  dataPointsColor={colors.text}
  yAxisTextStyle={{color: colors.fieldText, fontWeight: 700}}
  xAxisLabelTextStyle={{
   color: colors.fieldText, 
   fontSize: moderateScale(12), 
   fontWeight: 700
  }}
/>

How can I turn this component or any react native component into plain html so that i can use it in RNHTMLtoPDF?

I tried using renderToStaticMarkUp but it did not display the chart.

Requesting HTML of open loaded page (with infinite scrolling) in Python without Selenium [closed]

I’m trying, for no reason at all but personal satisfaction, to scrape some websites that have infinite scrolling using Python (I guess they work with JavaScript, but I don’t know what it is, that’s what I’m guessing from consulting lots of pages on this website — Instagram is the website I was trying on, with public profiles, but it’s the same as like YouTube).
I do not want to use Selenium, as I don’t know what it does and I don’t know if I can trust it — and I don’t know a lot of things about it.
I can manage to get to a certain page and load it as far down as I want using Python, but I cannot seem to be able to get the HTMLs of the page from which I could get all the content inside the page (excuse me if I’m saying something incorrect, I’m not an expert at all about this). At least, that’s what I think is an HTML: the working code for limited data (due to not loading the page) works with command “httpx.Client().get({url})” from “import httpx” and gets processed with “json.loads()” from “import json”.

What I would need right now is something to replace Selenium’s command “{webdriver.Firefox().}page_source” from which I’d obtain stuff to be parsed with beautifulsoup4. I also cannot use Selenium because when I execute the code the browser opens in another way (not with Selenium’s webdriver, that seems to cause me some problems) (I also cannot find Selenium’s source code).

Otherwise, I would need something (most likely something like a “get” request) to get stuff from the page that I loaded, that would then be processed with “json.loads()” from “import json” (I have a working code that extracts stuff from a page using json.loads(), but I have limited amount of data since the “get” request that I’m using doesn’t load the full page).

Using “requests_html” doesn’t work for me: I cannot seem to be able to install Chromium on my pc, and I keep having problems with “async” functions (that I don’t know what are there for).

I wanna emphasise that the page that I want to extract data from is already open and fully loaded (at least to a point where I’m satisfied with the amount of content) in a Firefox window.

Can anyone help me? I haven’t seen an updated discussion about this, latest (few) ones are from at least a year ago; most of them are from way back (around 2014-2018, and they talk about modules that are not kept up to date anymore).

Requesting HTML of open loaded page (with infinite scrolling) in Python without Selenium

Good evening,

I’m trying, for no reason at all but personal satisfaction, to scrape some websites that have infinite scrolling using Python (I guess they work with JavaScript, but I don’t know what it is, that’s what I’m guessing from consulting lots of pages on this website — Instagram is the website I was trying on, with public profiles, but it’s the same as like YouTube).
I do not want to use Selenium, as I don’t know what it does and I don’t know if I can trust it — and I don’t know a lot of things about it.
I can manage to get to a certain page and load it as far down as I want using Python, but I cannot seem to be able to get the HTMLs of the page from which I could get all the content inside the page (excuse me if I’m saying something incorrect, I’m not an expert at all about this). At least, that’s what I think is an HTML: the working code for limited data (due to not loading the page) works with command “httpx.Client().get({url})” from “import httpx” and gets processed with “json.loads()” from “import json”.

What I would need right now is something to replace Selenium’s command “{webdriver.Firefox().}page_source” from which I’d obtain stuff to be parsed with beautifulsoup4. I also cannot use Selenium because when I execute the code the browser opens in another way (not with Selenium’s webdriver, that seems to cause me some problems) (I also cannot find Selenium’s source code).

Otherwise, I would need something (most likely something like a “get” request) to get stuff from the page that I loaded, that would then be processed with “json.loads()” from “import json” (I have a working code that extracts stuff from a page using json.loads(), but I have limited amount of data since the “get” request that I’m using doesn’t load the full page).

Using “requests_html” doesn’t work for me: I cannot seem to be able to install Chromium on my pc, and I keep having problems with “async” functions (that I don’t know what are there for).

I wanna emphasise that the page that I want to extract data from is already open and fully loaded (at least to a point where I’m satisfied with the amount of content) in a Firefox window.

Can anyone help me? I haven’t seen an updated discussion about this, latest (few) ones are from at least a year ago; most of them are from way back (around 2014-2018, and they talk about modules that are not kept up to date anymore).

Thank you in advance.

I cannot implement new code into existing code [closed]

I am trying to make a web card game with my limited programming knowledge and the help of AI.

The problem is that I was iterating on the code (index.html) but I did not like the styles of the card variants, so I tried to make them separately (showcase-effects.html) until I ended up liking them.

The thing is, no matter how hard I try to integrate the code from showcase-effects.html into the main index.html, I end up breaking everything.

I’ve tried changing the last function to showcase-effects.html, but it doesn’t work properly or it breaks the animations, glow or album. The effects themselves don’t transfer properly to index.html neither.

I’ve made sure to change the function calls when deleting/changing functions (all 15 times, haahhahha), but nothing truly works 🙁

Both htmls are in my githu repo: https://github.com/D6ni/FootballTCG

Having 3 buttons at the same height

This might be something really simple and I’m just complicating things for myself. Tried multiple things and wasn’t able to accomplish the following:

I have 3 columns (cards) with text and a button underneath. The middle one has a hover functionality, where it shows a when hovered over.
The problem? The buttons don’t align horizontally. I’d like them to be at the same level. How do I align the 3 buttons without changing other components?
I know I can just bottom:240px; but what if I don’t know the specific height?

Here is the relevant part of the code:

        <!-- 1) Café-Concert & more -->
        <article class="card">
          <div class="card-body">
            <h3>Café-Concert & more</h3>
            <p class="card-text">A lot of text</p>
          </div>
          <div class="card-actions mt-3">
            <a class="btn" href="mailto:{{email}}?subject=Offer%20request%20%E2%80%94%20Caf%C3%A9%E2%80%91Concert">
              Get an offer
            </a>
          </div>
        </article>

        <!-- 2) Lectures & workshops -->
        <article class="card reveal-list">
          <div class="card-body">
            <h3>Lectures &amp; Workshops</h3>
            <p class="card-text">A lot of text</p>
          </div>
          <div class="card-actions mt-3">
            <a class="btn" href="mailto:{{email}}?subject=Offer%20request%20%E2%80%94%20Lecture%20%26%20Workshop">
              Get an offer
            </a>
          </div>
          <ul class="mt-2">
            <li>What is HIP: history, milestones, where we are now.</li>
            <li>
              Building blocks of HIP: sources, instruments, articulation, tempo,
              ornamentation, continuo.
            </li>
            <li>
              The early keyboard family: harpsichord, spinet, clavichord, square
              piano.
            </li>
            <li>National styles: England, France, Germany, Italy.</li>
            <li>
              Basso continuo, from figures to music, with singers or
              instrumentalists.
            </li>
            <li>
              Tailored sessions: happy to adapt topics or combine lecture and
              workshop in one visit.
            </li>
          </ul>
        </article>

        <!-- 3) Consultation -->
        <article class="card">
          <div class="card-body">
            <h3>Consulting & Coaching</h3>
            <p class="card-text">A lot of text</p>
          </div>
          <div class="card-actions mt-3">
            <a class="btn" href="mailto:{{email}}?subject=Offer%20request%20%E2%80%94%20Consultation">
              Get an offer
            </a>
          </div>
        </article>
      </section>


/* Cards, grids */
.grid {
  display: grid;
  gap: 16px;
}
.cards-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch; /* ensure grid items fill row height */
}

.card {
  background: #fff;
  border: 1px solid var(--border, #ece7de);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.03);
  display: flex; /* key */
  flex-direction: column; /* key */
}
.card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}
.card p {
  margin: 0;
  color: #555;
  font-size: 14px;
}

.card-actions {
  margin-top: auto; /* pushes this block to the bottom */
  text-align: center; /* center the button horizontally */
}
.card-actions .btn {
  display: inline-block; /* keeps the button sized nicely when centered */
}

.reveal-list ul {
  max-height: 0; /* hide the list */
  overflow: hidden;
  opacity: 0;
  transform: translateY(-4px);
  margin-top: 0; /* override .mt-2 while hidden */
  transition: max-height 0.35s ease, opacity 0.25s ease, transform 0.35s ease,
    margin-top 0.2s ease;
}

/* Show when the card is hovered (mouse) or focused (keyboard/tab) */
.reveal-list:hover ul,
.reveal-list:focus-within ul {
  max-height: 600px; /* big enough to contain the list */
  opacity: 1;
  transform: translateY(0);
  margin-top: 8px; /* restore spacing when open */
}

Facebook stylex react native

According to library authors https://stylexjs.com/blog/introducing-stylex/ this should work as well in web as in react native:

We created StyleX not only to meet the styling needs of React developers on the web, but to unify styling for React across web and native.

The problem is that i am unable to make it work in react native. I have library installed, I have added “@stylexjs/babel-plugin” to plugins array in babel.config.js and in the src/components/button I have code

import { Pressable, Text } from "react-native";
import * as stylex from "@stylexjs/stylex";

export const styles = stylex.create({
  button: {
    backgroundColor: "#00FFFF",
    fontSize: 24,
    height: 50,
  },
  text: {
    color: "#663399",
  },
});

type Props = {
  children: string;
};

export const Button = ({ children }: Props) => {
  console.log(stylex.props(styles.button));
  return (
    <Pressable style={stylex.props(styles.button).style}>
      <Text {...stylex.props(styles.text)}>{children}</Text>
    </Pressable>
  );
};

console.log produces this output: {“className”: “x1lt72u0 x1pvqxga x10wjd1d”}
so clearly it is working, just not the way react native would expect stylex.props(styles.button).style returns undefined, if someone knows how to make stylex work in react native i would higly appreciate some help here. And how on earth there is nothing about react native in the documentation. Its facebooks product! 🙁
I oult not fined any mentions on stylex github discusions, maybe stylex does not work in react native after all? ;p Thanks for any help.

React useEffect causing infinite re-render when updating state from async call [closed]

We are developing a React application for our company. In one of our components, we are fetching data from an API inside useEffect and updating the state. But the component goes into an infinite re-render loop, and the browser slows down.

I tried changing the dependency array to [], but then the API didn’t re-fetch when the filter changed.
I also tried moving the fetch function outside the useEffect, but it still caused unwanted renders.
I expect the API call to run only once when the component mounts and again only when the filter value changes.