Closed Bug 1912809 Opened 1 year ago Closed 1 year ago

setPointerCapture() causes an onclick event for the wrong element (INVALID)

Categories

(Firefox :: Untriaged, defect)

Firefox 129
defect

Tracking

()

RESOLVED INVALID

People

(Reporter: octogonz, Unassigned)

Details

Attachments

(1 file)

Attached file bug.html

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:129.0) Gecko/20100101 Firefox/129.0

Steps to reproduce:

A complete repro file is attached. The problem occurs when a control is using setPointerCapture() to act like a button, for example this div:

HTML:

    <div
      class="button"
      onmousedown="buttonDown(event)"
      onmouseup="buttonUp(event)"
    >
      MOUSEDOWN HERE
    </div>

JavaScript:

      function buttonDown(event) {
        // The repro works even without this line:
        event.preventDefault();

        event.currentTarget.setPointerCapture(event.pointerId);
      }
      function buttonUp(event) {
        // The repro works even without this line:
        event.currentTarget.releasePointerCapture(event.pointerId);
      }

Steps:

  1. Click on this div, holding the mouse down.
  2. Drag the mouse over some unrelated element on the page, let's call it the mousedown element.
  3. Release the mouse over the target element. We'll call that the mouseup element.

Actual results:

In Chrome, the mouseup element does not receive any mouse events, because the mouse is captured.

Expected results:

In Firefox, the mouseup element incorrectly receives an "onclick" event (but not mousedown or mouseup). If it is an <a> tag, Firefox will actually navigate to its href URL.

A better wording of the steps:

Steps:

  1. Click on this "mousedown" div, holding the mouse down.
  2. Drag the mouse over some unrelated element on the page. Let's call that the "mouseup" element.
  3. Release the mouse over the "mouseup" element.

Let me resubmit this. Bugzilla doesn't allow me to edit what I wrote.

Status: UNCONFIRMED → RESOLVED
Closed: 1 year ago
Resolution: --- → INVALID
Summary: setPointerCapture() causes an onclick event for the wrong element → setPointerCapture() causes an onclick event for the wrong element (INVALID)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: