Skip to content

[FIX] Fix ElementComponent 'mousemove' event firing outside element#8288

Merged
willeastcott merged 2 commits into
mainfrom
fix-mousemove
Dec 20, 2025
Merged

[FIX] Fix ElementComponent 'mousemove' event firing outside element#8288
willeastcott merged 2 commits into
mainfrom
fix-mousemove

Conversation

@willeastcott

@willeastcott willeastcott commented Dec 20, 2025

Copy link
Copy Markdown
Contributor

Fixes #4755

Overview

When the left mouse button was pressed inside an ElementComponent, mousemove events would continue to fire on that element even after the mouse cursor moved outside its bounds. This was a regression from engine version 1.55.0.

Changes

  • mousemove events now only fire on the element currently under the mouse cursor
  • mouseup events still fire on the originally pressed element to maintain proper click detection
  • mouseenter/mouseleave events continue to work correctly for hover state tracking

Technical Details

The _onElementMouseEvent method was incorrectly "capturing" both mousemove and mouseup events when an element was pressed. This capture behavior is only needed for mouseup to properly detect clicks (comparing pressed element vs hovered element).

The fix changes the condition from:

if ((eventType === 'mousemove' || eventType === 'mouseup') && this._pressedElement)

to:

if (eventType === 'mouseup' && this._pressedElement)

This ensures mousemove is only dispatched to the element the cursor is actually over, while mouseup continues to be dispatched to the pressed element for click detection logic.

Demonstration of Fix

mousemove-bug.mp4

Checklist

  • I have read the contributing guidelines
  • My code follows the project's coding standards
  • This PR focuses on a single change

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a regression where mousemove events incorrectly continued firing on an ElementComponent after the mouse cursor moved outside its bounds while the left button was pressed. The fix restores the expected behavior where mousemove events only fire on the element currently under the cursor.

Key Changes:

  • Modified event capture logic to only apply to mouseup events, not mousemove
  • Updated inline comment to reflect the narrower scope of event capture
  • Maintains proper click detection by keeping mouseup capture behavior

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/framework/input/element-input.js Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@willeastcott willeastcott merged commit 33e0e63 into main Dec 20, 2025
7 checks passed
@willeastcott willeastcott deleted the fix-mousemove branch December 20, 2025 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ui UI related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ElementComponent 'mousemove' event fires outside element when LMB is pressed

3 participants