Skip to content

fix: dispatch mouseUp to the widget that received mouseDown - #846

Open
NemeZZiZZ wants to merge 1 commit into
klinecharts:mainfrom
NemeZZiZZ:fix/mouseup-mousedown-widget
Open

fix: dispatch mouseUp to the widget that received mouseDown#846
NemeZZiZZ wants to merge 1 commit into
klinecharts:mainfrom
NemeZZiZZ:fix/mouseup-mousedown-widget

Conversation

@NemeZZiZZ

Copy link
Copy Markdown
Contributor

Problem

mouseDownEvent remembers which widget received the press (this._mouseDownWidget = widget, Event.ts:312), but mouseUpEvent ignores it and re-hit-tests at the release position:

mouseUpEvent(e: MouseTouchEvent): boolean {
  const { widget } = this._findWidgetByEvent(e)   // widget under the cursor NOW
  ...
  consumed = widget.dispatchEvent('mouseUpEvent', event)

The mouseup listener lives on documentElement, so releasing outside the chart still reaches this handler — but dispatches to whatever happens to be under the cursor (another pane's widget, an axis, the separator) or to nothing.

Impact

Dragging an overlay point or continuous-drawing with the button released over an axis/separator: the main widget never gets its mouseUpEvent, so OverlayView's mouse-up path (setPressedOverlayInfo({ overlay: null }), forceComplete()) never runs — the overlay stays pressed/unfinished until the next click on the main area.

Fix

Standard mouse-capture semantics: dispatch mouseUpEvent to the widget that received the mouseDownEvent, falling back to the hit-test only when no press is tracked:

const widget = this._mouseDownWidget ?? this._findWidgetByEvent(e).widget

_makeWidgetEvent then also computes event-local coordinates against the widget that actually handles the event, which is correct under capture. _mouseDownWidget was already tracked for the separator-drag path (Event.ts:387); this extends the same semantics to mouse-up.

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.

1 participant