GenClass is open source.Star on GitHub

Button does nothing when clicked: 7 causes and how to find them.

A button that does nothing and logs no error has one of two problems. Either it never gets the click, because a layer on top or a CSS rule sends it elsewhere, or it gets the click and the code behind it never runs or never finishes. One call to document.elementFromPoint() in the DevTools Console tells you which. The fix is usually to remove the layer or let clicks through it, or to move the handler's cleanup into finally and give its request a timeout.

First check: what the click hits

Select the button in the Elements panel, then run this in the Console:

const r = $0.getBoundingClientRect();
const x = r.left + r.width / 2;
const y = r.top + r.height / 2;
document.elementFromPoint(x, y);   // what a click at the center hits
document.elementsFromPoint(x, y);  // everything there, topmost first

elementFromPoint() returns the topmost element at a point and skips elements with pointer-events: none (MDN); elementsFromPoint() lists every element at that point, topmost first (MDN). $0, the element selected in the Elements panel, is part of Chrome's Console Utilities API, which works only in the DevTools Console, not in page scripts (Chrome docs).

What the hit test tells you
The hit test returnsLikely causeSection
Another elementA layer, a pseudo-element or a fixed bar on top.1, 2
Something behind the buttonpointer-events: none or inert on it or a parent.3
The button, then a reloadIt submits its form.4
The button, no handler runsNo listener on this node.5
The button, stuck disabled or busyA lock never released, or a hung request.6, 7

1. Something invisible is on top

  • A modal or drawer backdrop that faded to opacity: 0 but stayed in the page.
  • A closed dropdown panel under a sticky header, hidden with opacity: 0.
  • A ::before or ::after stretched over a card, as in Bootstrap's stretched link (Bootstrap). Clicks there go to the element that owns it, so the hit test returns that element, not your button.
  • A fixed footer, bottom bar, chat bubble or cookie banner over the last button on a phone, even at the end of the page.

Remove the layer when it closes. If it must stay, let clicks through it:

.overlay { pointer-events: none; }         /* clicks pass through */
.overlay .panel { pointer-events: auto; }  /* except on its panel */

For a fixed bottom bar, pad the page bottom by the bar's height.

2. A stacking context keeps it underneath

A higher z-index often changes nothing, because z-index only orders elements within one stacking context. An ancestor with transform, filter, opacity below 1, position: fixed or sticky, or a positioned element with a z-index other than auto starts its own context (MDN). A button with z-index: 9999 in a card with a transform still sits under a fixed header with z-index: 10.

This is also how a modal ends up behind its backdrop: the backdrop is a child of <body>, while the modal's z-index only counts inside a container with its own stacking context. Put the modal markup at the top level of the page, as Bootstrap's docs advise (Bootstrap), or open a <dialog> with showModal(), which puts it in the top layer above the rest of the page (MDN).

3. pointer-events or inert switches it off

With pointer-events: none an element is not the target of clicks, and the property is inherited (MDN). A class like .is-loading { pointer-events: none; } on a wrapper switches off every button inside it, unless a child sets pointer-events: auto. The inert attribute blocks clicks and focus for a whole subtree (MDN), and hit testing treats inert content as if it had pointer-events: none (HTML standard). When dialog code leaves pointer-events: none on <body> after it closes, the whole page goes dead: see page frozen after a modal closes.

4. The button submits its form

A <button> with no type inside a <form> is a submit button (MDN). Your handler runs, then the browser submits the form and loads a page, often the same one, so whatever the handler did is gone. The reload also clears the Console unless Preserve log is on (Chrome docs). Mark every other button type="button":

<form>
  <button type="button">Apply coupon</button>
  <button type="submit">Pay</button>
</form>

For the real submit, handle the form's submit event and call event.preventDefault() if your code sends the data.

5. Nothing listens on the button you see

addEventListener() binds to one DOM node. If code rebuilds that part of the page, for example with innerHTML after a fetch, the button on screen is a new node without your listener (MDN). getEventListeners() and monitorEvents() show it. They are Console Utilities too, not page JavaScript:

getEventListeners($0);       // { click: [...] }, or {} if nothing listens here
monitorEvents($0, "click");  // logs each click the button receives
unmonitorEvents($0);

In React an empty result is normal: since React 17, React attaches its listeners to the root container (React blog). There, look for onClick={handleClick()}, which calls the function during render instead of on the click (React docs). Without a framework, listen on a parent that is never replaced:

document.addEventListener("click", (event) => {
  const button = event.target.closest("[data-action='save']");
  if (button) save(button.dataset.id);
});

6. A disabled state or lock is never released

A disabled button gets no click events, and neither does a button inside a <fieldset disabled> (HTML standard). Code that enables the button only on success leaves it dead after one failure. A double-submit guard breaks the same way when an early return or an error skips the release:

let busy = false;
async function submit() {
  if (busy) return;
  busy = true;
  const order = readForm();
  if (!order) return;           // returns with busy still true
  await api.placeOrder(order);  // a throw here also leaves busy true
  busy = false;
}

Release the lock and enable the button in finally, as under cause 7. Why to keep the guard: preventing duplicate submissions.

7. The handler waits for a request that never answers

finally runs only when the awaited promise settles. If the server never answers, the button stays disabled and nothing is logged. fetch() has no timeout option (MDN). Pass AbortSignal.timeout() as its signal, and a hung request rejects with a TimeoutError (MDN):

async function submit(button) {
  const order = readForm();
  if (!order) return;           // check before taking the lock
  button.disabled = true;
  try {
    const res = await fetch("/api/orders", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify(order),
      signal: AbortSignal.timeout(15000),
    });
    if (!res.ok) throw new Error(`HTTP ${res.status}`);
  } catch (err) {
    showError(err);             // TimeoutError after 15 s
  } finally {
    button.disabled = false;    // after success, error or timeout
  }
}

More on hung requests: fetch that never resolves.

Dead clicks and rage clicks

In production, session replay tools can flag a dead button. Sentry's Session Replay counts a dead click when a click on a button, link or input brings no DOM change or scroll within 7 seconds, and a rage click when such an element gets 3 or more clicks in that window (Sentry docs). Microsoft Clarity flags a click that gets no feedback in a reasonable time as a dead click, and rapid clicks in one area as rage clicks (Clarity docs).

Use the counts to find the element, then reproduce it and run the hit test. Buttons that change nothing by design, such as Print or Download, add noise; Sentry's slowClickIgnoreSelectors option leaves them out. A button stuck disabled may not show up at all, because the browser dispatches no click event on a disabled control.

Where GenClass fits

GenClass's runtime has measured visual checks: deterministic measurements with documented thresholds and no model. Findings print in the console with the element and a suggested fix. click-blocked reports a transparent layer over at least 30% of the viewport, with a visible control under it, that takes a second click within 3 seconds while nothing on the page changes. control-unreachable reports a control covered by a fixed or sticky element once the page is scrolled to the end. request-stalled reports a fetch or XHR request pending for 15 seconds (the default), with the control the page disabled for it.

With faults planted into GenClass's demo, template and compatibility apps, click-blocked found 12 of 18, missing only on demo pages whose DOM never stops changing, and control-unreachable 32 of 32, with 0 false reports in 128 page views of the unmodified apps. On the six demo apps, request-stalled found 11 of 18 planted 60-second hangs, with 0 false reports in 120 runs; naming the disabled button is covered by unit tests only. All of this is from Chromium, and the false-report rate on other apps and sites is not known.

The checks run on development hosts such as localhost by default. These three checks report only the covers described above and none of causes 3 to 6; control-unreachable skips bars with controls of their own, such as cookie banners. To try them, run npx genclass in your app's folder: it signs you in (a free account is enough) and adds GenClass in observe mode, the default, which only reports. Then use your app on localhost and watch the console.

Questions

About buttons that do nothing.

Why does my button do nothing when clicked, with no error?

Usually a layer on top takes the click, or the click lands but the code behind it never runs or never finishes. Run document.elementFromPoint() at the button's center in the DevTools Console to tell which.

How do I find which element is blocking clicks?

Select the button in the Elements panel and run document.elementFromPoint() at its center in the Console: it returns the element the click lands on. document.elementsFromPoint() lists every element at that point, topmost first.

How do I make clicks go through an overlay?

Set pointer-events: none on the overlay, and pointer-events: auto on any part of it that must stay clickable.

Why doesn't a higher z-index fix it?

z-index only orders elements within one stacking context, and an ancestor with transform or opacity below 1 starts a new one. Move the element out of that ancestor, or give the ancestor position: relative and a z-index above the layer that covers it.

What is the difference between dead clicks and rage clicks?

A dead click is a click the page does not respond to. A rage click is several fast clicks in one spot, which Sentry counts as three or more clicks on an element that did not respond within 7 seconds.

Talk to sales

Tell us about your team and what you need. A person writes back, usually within a day.