Automating Drag-and-Drop in React/MUI Apps with Playwright
One of our customers recently faced an issue with automating drag-and-drop functionality in their React application built with Material-UI (MUI). While we provided a solution for them with DevAssure, I also wanted to share a general approach to handling drag-and-drop interactions in React/MUI apps using Playwright.
Automating drag-and-drop in modern web applications sounds straightforward. Playwright even provides a built-in dragTo method. But if you’ve ever tried it in a React/MUI (Material-UI) app, you’ve probably seen mysterious timeouts or errors like:
locator.dragTo: Timeout 30000ms exceeded
<div class="MuiBackdrop-root ..."> intercepts pointer events
I did a deep dive to understand why this happens and how to fix it and Here's what I found.
The Problem: MUI Overlays
Material-UI uses two common overlay components:
- MuiBackdrop: a full-screen, often invisible element behind modals/popovers.
- MuiPopover: the floating menu/panel itself.
Even when they look hidden or transparent, these elements are still in the DOM with pointer-events: auto. That means they intercept clicks, drags, and drops — preventing your drop target from ever receiving the event.
Playwright sees the element you’re dragging to, but the mouseup (or final part of the drag sequence) hits the invisible overlay instead of your canvas, resulting in the error.
