PageVeilBehavior: a click on a button that leaves a field updating on change is lost

Open
#1,944 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
56/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
java, javascript
Domain
frontend, web-dev

Research direction

Start with wicket-veil.js and the /ajax/call/beforeSend veil handling described in the issue. Trace how pointer events interact with the veil and how the script identifies elements after an Ajax response replaces them. Done means the described button click runs once, while the listed detached, hidden, disabled, and intervening-press cases are skipped.

Written by the indexing model from the issue text.

Description

Affects: 11.0.0 and current master
Component: wicket-extensions, PageVeilBehavior, wicket-veil.js

What happens

A page with PageVeilBehavior, a field that updates the server on change, and a button:

add(new PageVeilBehavior());
field.add(new AjaxFormComponentUpdatingBehavior("change") {
    @Override
    protected void onUpdate(AjaxRequestTarget target) {
        Thread.sleep(1000); // a round trip longer than a click
    }
});
form.add(new AjaxButton("save") {
    @Override
    protected void onSubmit(AjaxRequestTarget target) {
        runs.incrementAndGet();
    }
});

Type something in the field, then click Save once with the mouse. The field's request is sent, but Save never runs: runs stays 0. Without PageVeilBehavior, Save runs once.

Checked with a real mouse click through WebDriver in Chrome 155 and Firefox 124.

Cause

  1. The press on Save moves the focus, so the field fires change within the mousedown.
  2. The channel is free, so Wicket sends the request at once, and the veil is appended to body in /ajax/call/beforeSend, before the mouse comes up.
  3. The mouseup lands on the veil. The browser fires click on the nearest common ancestor of the mousedown and mouseup targets, here body, not on the button.

The user sees the field saved and Save doing nothing. This happens whenever the field's round trip lasts longer than the press, and every form with an updating field is open to it.

Fix proposed

In wicket-veil.js:

  1. Remember the element of a pointerdown made while no veil covered it.
  2. If the matching pointerup lands on a veil, call click() on that element once the veil is lowered.
  3. Skip the replay if the element is no longer in the page, is hidden or disabled, or if a new press started meanwhile. If the answer replaced the element, replay on the element now carrying the same id.

Workaround

None short of patching the veil's script: the click is never fired, so the application has nothing to listen to.

Related: #1631, #1942. Found while working on reiern70/advanced-widgets#141.

Dominant language
Java
Stars
800
Forks
437
Avg merge
21h 36m
Merged PRs (30d)
167

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/wicket

All issues in apache/wicket

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.