Skip to content

fix: listen for drag events in the stage owner window - #2066

Merged
lavrton merged 1 commit into
konvajs:masterfrom
darkdi:fix/1980-drag-owner-window
Aug 25, 2026
Merged

lavrton merged 1 commit into
konvajs:masterfrom
darkdi:fix/1980-drag-owner-window

Conversation

@darkdi

@darkdi darkdi commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Fixes #1980.

Konva installs its global drag listeners on the module's original window. When a stage is rendered inside an iframe or popout window, mouse/touch move and end events are emitted by that stage's owner window instead, so dragging either does not start correctly or continues only when the pointer moves over the original window.

This change registers the existing drag handlers on each stage's ownerDocument.defaultView the first time a drag element is created. A WeakSet prevents duplicate listener registration while allowing closed iframe/popout windows to be collected. The original browser window is still registered at module initialization, so existing behavior is unchanged.

The regression test creates a stage inside an iframe, starts a draggable rectangle, and dispatches native mousemove / mouseup events on the iframe window. It verifies the node moves and receives dragend from that owner window.

Register drag listeners on the window that owns each stage so draggable nodes keep receiving move and end events when Konva is rendered in an iframe or popout window.

Refs konvajs#1980
@darkdi
darkdi marked this pull request as ready for review August 21, 2026 09:32
lavrton added a commit that referenced this pull request Aug 25, 2026
Use the window the stage is rendered in - an iframe or a popout window - for drag and transform events, animation frames and visibility.
@lavrton
lavrton merged commit 49f9d53 into konvajs:master Aug 25, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drag events in popout windows listen on the original window

2 participants