A junior ships a 10-line dialog. position: fixed; inset: 0 for the overlay, a centered panel, a useState. Passes Figma. Ships. A week later the bug queue lights up.
A code reviewer with a mouse and a Chrome browser clicks the panel. It opens. Clicks Close. It closes. Approves the PR. Ships on Friday. But the <div> in that 10-line dialog is not sealing anything — it is sitting on the page like any other block element. Three situations are about to land in the bug queue.
// The 10-line version every junior ships first.// Works in the reviewer's mouse-and-Chrome demo. Fails silently for// seven user groups the moment it ships.function BrokenDialog({ open, onClose, children }) { if (!open) return null; return ( <div className="fixed inset-0 bg-black/50 flex items-center justify-center"> <div className="bg-white p-6 rounded-lg"> {children} <button onClick={onClose}>Close</button> </div> </div> );}// Seven silent failures:// 1. position: fixed broken inside transform-ancestor (containing// block collapse — overlay covers parent panel, not viewport)// 2. Tab leaves the dialog and lands behind the overlay (no trap)// 3. Screen reader walks background content (no inert / aria-hidden)// 4. Esc does nothing (no keydown handler)// 5. Backdrop click does nothing (no pointerdown handler)// 6. Focus vanishes on close (no restore)// 7. Page scrolls behind on iOS + jumps 15px on desktop (no lock)This will remove the selected item.
The simulator above is running the naive version. The panel opens; a 16-row product card sits behind. Try scrolling the page behind — it moves. Try clicking one of the “Buy” buttons peeking from under the panel — it fires. Nothing is sealed; the <div> is just another block in the flow. Predict what each probe reveals before you tap through.
Open the panel in the simulator. Scroll on the page behind it — drag the scrollbar or wheel on any row. Try clicking one of the “Buy” buttons that peeks from under the panel. What's actually happening?
The naive panel above has no position: fixed, no backdrop, no higher z-index. With the panel OPEN, what happens when the user scrolls the page and clicks a button that sits underneath the panel?