Skip to content

Replay a click whose release lands on an Ajax veil raised during the press - #1996

Open
reiern70 wants to merge 3 commits into
masterfrom
veil-lost-click-1944
Open

reiern70 wants to merge 3 commits into
masterfrom
veil-lost-click-1944

Conversation

@reiern70

@reiern70 reiern70 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1944

Stacked on #1995 (GitHub issue #1943). Its base is veil-keyboard-1943, so the diff shows only this fix. Merge #1995 first; GitHub then retargets this PR to master.

With a page veil, a field updating on change and a button next to it, a click on the button right after typing into the field was lost. Pressing the button takes the focus from the field, which fires its change within the mousedown; the channel is free, so the request is sent at once and the veil is appended before the mouse button comes up. The mouseup lands on the veil, and the browser clicks the nearest common ancestor of the mousedown and mouseup targets, body, not the button. The field was saved and the button did nothing, whenever the field's round trip outlasted the press. A tap on a touch screen loses its click the same way.

What it does now

  • Wicket.Veil remembers the element of a mousedown that does not land on a veil. When the matching mouseup lands on a veil, it works out the element the browser would have clicked without the veil, the common ancestor of the pressed element and the element under the veil at the release point, and calls click() on it once the veil is lowered and no other veil covers it.
  • Nothing is replayed when that ancestor holds the veil, because the browser's own click reached it, as for a press dragged off the button onto the page. So the replay only ever reaches the pressed element or one of its ancestors.
  • The replay is skipped when the element is hidden or disabled by then, or when a new press started outside the veil meanwhile. A press on the veil leaves it pending.
  • If the response replaced the element, the click goes to the element now carrying its id, or that of its closest ancestor with an id that does not hold the veil.

The issue proposed pointerdown/pointerup. Mouse events are used instead: with touch, the change, and so the veil, comes after the pointerup, which then never lands on the veil. The compatibility mouse events see the lost click for the mouse and for touch alike (checked in Chrome and Firefox).

What applications see

The click that was lost before now reaches the button once the veil is lowered. It goes through HTMLElement.click(), so the replayed event is not trusted, carries no coordinates and does not move the focus. No API change, nothing to migrate.

Backport

To wicket-11.x in #2002, a clean cherry-pick, stacked on #2001. wicket-10.x has no veil.

Tests

  • Nine new QUnit tests in veil-test.js, with elements fixed on screen so hit-testing works; six fail without the fix.
  • VeilPage gets a field updating on change in one second next to a Save button. VeilPageSeleniumTest clicks Save with a real mouse and taps it with a real touch right after typing, and drags a press off Save onto the field; each checks that the release really landed on the veil. Without the fix the click and tap cases fail in Chrome and Firefox (Save never runs). All 36 cases pass in both.
  • mvn clean verify -Pjs-test is green.

…press

With a page veil, a field updating on change and a button next to it, a
click on the button right after typing into the field was lost. Pressing
the button takes the focus from the field, which fires its change event
within the mousedown; the channel is free, so the request is sent at once
and the veil is appended before the mouse button comes up. The mouseup
lands on the veil, and the browser clicks the nearest common ancestor of
the mousedown and mouseup targets, the body, not the button. The field was
saved and the button did nothing, whenever the field's round trip outlasted
the press. A tap on a touch screen loses its click the same way: the
compatibility mousedown that moves the focus comes after the pointerup.

Wicket.Veil now remembers the element of a mousedown that does not land on
a veil. When the matching mouseup lands on a veil, it works out the element
the browser would have clicked without the veil, the common ancestor of the
pressed element and the element under the veil at the release point, and
clicks it once the veil is lowered and no other veil covers it. Nothing is
replayed when that ancestor holds the veil, because the browser's own click
reached it, as for a press dragged off the button onto the page. The
replay is skipped when the element is hidden or disabled by then, or when
a new press started outside the veil meanwhile; a press on the veil leaves
it pending. If the response replaced the element, the click goes to the
element now carrying its id, or that of its closest ancestor with an id
that does not hold the veil.

The issue proposed pointerdown and pointerup. The mouse events are used
instead because with touch the change event, and so the veil, comes after
the pointerup, which then never lands on the veil; the compatibility mouse
events see the lost click for the mouse and for touch alike.

An application sees the click it lost before: the button's handlers run
once the veil is lowered, through HTMLElement.click(), so the replayed
event is not trusted and carries no coordinates.

VeilPage gets a field updating on change next to a Save button, and
VeilPageSeleniumTest clicks Save with a real mouse and taps it with a real
touch right after typing, and drags a press off Save onto the field.

GitHub issue #1944

@papegaaij papegaaij 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.

The replay approach makes sense to me, but I found a few problems with when and how the click is replayed, plus some test gaps. Details inline.

Missing tests: no QUnit test covers a stale press (see the onMouseDown comment), a click with a modifier key held, or a replay onto an ancestor below body or the host.

# Conflicts:
#	wicket-extensions/src/test/js/veil-test.js
…ly once

Review of the click replay of Wicket.Veil found these problems:

- A press on the veil returned early without forgetting the press before
  it, and only a left mouseup forgot it. When the mouseup of a press never
  came, as for a link dragged away, which fires dragstart and dragend but
  no mouseup, a later click on a veil raised by a request the mouse did
  not start was replayed on that element once the veil was lowered. A
  press on the veil and a dragstart now forget the press, and a pending
  replay stays in place.
- The browser still sends its own click to the common ancestor of the
  pressed element and the veil: the host of a local veil, the body for the
  page veil. A delegated click handler on a veiled row ran once for that
  click and once more for the replay, and an Ajax click behaviour on the
  host sent two requests. When a replay is recorded, the click that comes
  with the release is dropped now if its target holds the veil; a click
  in a later task is left alone. Each press makes one click, the replayed
  one.
- HTMLElement.click() sends a click without ctrlKey, metaKey, shiftKey or
  altKey, so a Ctrl- or Cmd-click on a link released on the veil
  navigated the current tab, and a Shift-click lost its Shift. A release
  with a modifier held is no longer replayed, which leaves it as lost as
  it was without the replay.
- A mouse event sent to the document or to a text node threw a TypeError
  in the window listeners; those targets are ignored now.

New QUnit tests cover a press whose release never came, a dragged element,
the modifiers, the browser's click on the host and on the body, a replay
onto an ancestor below the body, and mouse events sent to the document or
a text node. VeilPageSeleniumTest records the clicks that reach the
window: a click or tap released on the veil makes one click, on Save, and
a press dragged off Save onto the field one click, on their form. That
test was named as if nothing were replayed for it, and is renamed.

An application no longer gets the browser's click on the veiled host or
the body next to a replayed click, and gets no click for a release with a
modifier held.

GitHub issue #1944
@reiern70

Copy link
Copy Markdown
Contributor Author

Thanks for the review. cdf7eba addresses the inline comments, and the missing tests are in veil-test.js now: a stale press (a press on the veil, and a dragstart), the four modifier keys, and a replay onto an ancestor below the body (the form holding the button and the field). The merge before it, b4d65ee, brings in the keyboard fixes from #1995.

@reiern70
reiern70 requested a review from papegaaij November 23, 2026 21:35
Base automatically changed from veil-keyboard-1943 to master November 24, 2026 13:48
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.

2 participants