Back to feed
Dev.to
Dev.to
7/4/2026
Position: fixed is a paint trick, not an event boundary

Position: fixed is a paint trick, not an event boundary

Short summary

A CSS-fixed overlay's drag handlers weren't responding because the parent element was capturing pointer events via setPointerCapture, intercepting movement after the initial press. Position: fixed separates elements visually, not structurally in the DOM, so events still bubble to ancestors. Fix: call stopPropagation on the overlay's handlers or render the overlay as a portal at the document root.

  • Fixed positioning is orthogonal to event routing: visual separation doesn't prevent event bubbling to ancestors
  • setPointerCapture on a parent element intercepts all pointer events for child elements in the DOM tree
  • Synthetic pointer events in tests masked the bug—setPointerCapture requires real hardware pointers to activate

Generated with AI, which can make mistakes.

Is this a good recommendation for you?

Comments

Failed to load comments. Please try again.

Explore more