Repository navigation
Drop Enter and Space pressed on an element under an Ajax veil (11.x) - #2001
Merged
Merged
Conversation
The page and local veils were transparent divs that blocked only the mouse. The focus stayed on the element under the veil, so Enter or Space pressed again on a focused button activated it once more, and Enter in a text field submitted its form again: the request waited in the channel's queue and was sent as soon as the first one was done. An AjaxButton whose onSubmit takes a while ran twice when pressed twice from the keyboard, which is what the veil is there to prevent, and what a double click with the mouse did not do. While a veil is up, Wicket.Veil now drops, in the capturing phase on the window, the keydown of Enter and Space whose target it covers: any element for the page veil, the elements inside its host for a local veil. The keyup of a key it dropped is dropped too, even when the veil has come down meanwhile. Keys that type text are left alone: Space in a text field or a select, both keys in a textarea or in editable content, and any key during an IME composition. Other keys, Tab among them, are not touched, so the focus can still move, and a key pressed before the veil came up is released as usual. Making the veiled content inert would block the keyboard as well, but the page veil is a child of the body, so every other child of the body would have to be made inert, and inert content loses the focus and is hidden from assistive technologies while the request runs. An application that relied on the keyboard under a veil, a listener reacting to Enter or Space while a request runs for example, no longer gets those key events for the covered elements until the veil is lowered; its other key events are unchanged. VeilPage gets a form whose Save takes two seconds, and VeilPageSeleniumTest presses Enter and Space on it twice and types into its field under the veil with real key presses. The test can now drive Firefox too, with -Dwicket.selenium.browser=firefox, and waits for the page's own requests to be over before switching the Ajax engine, as Firefox otherwise finds the switch under the veil. veil-test.js is wrapped in a function like the newer test scripts, which re-indents it. GitHub issue #1943
This was referenced Nov 23, 2026
… a veil Review of the keyboard handling of Wicket.Veil found these problems: - A listener on the window sees a keydown from inside a shadow root retargeted to the shadow host, so a text field in a web component was classified by the tag name of its host, and Space was dropped in it under the veil: typing "a b" gave "ab". A key is now classified by the first element of the event's composed path, which is the field itself in an open shadow root. - The dropped keys were recorded on every keydown, auto-repeats included. Enter held on a button whose click raises the veil had its repeats dropped and recorded, so its keyup was dropped too, and a listener pairing keydown and keyup saw Enter still down. Space dropped under the veil and still held when the veil came down had its record removed by the next repeat, so its keyup passed and clicked the button. The first keydown of a press now decides on its release, and its repeats follow it: they are dropped when it was dropped, and otherwise only while the element is veiled. - Safari sends the Enter that commits an IME composition after compositionend, with isComposing already false. It is recognised by its keyCode 229 now. - A key sent to the window while only a local veil was up threw a TypeError from Node.contains(). Tag names are compared in lower case, so the fields of a document served as XHTML are recognised too. The QUnit tests checked that a key reached its element and was not cancelled in one boolean, so they still passed with preventDefault() or stopImmediatePropagation() removed from drop(). They check both apart now, and new tests cover held keys, a field and a button in a shadow root, the Enter with keyCode 229 and a key sent to the window. An application now gets Space typed into a text field of a web component under the veil, and the release of a key held since before the veil came up. GitHub issue #1943
Contributor
Author
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## wicket-11.x #2001 +/- ##
=================================================
- Coverage 62.71% 62.70% -0.01%
+ Complexity 11510 11507 -3
=================================================
Files 1254 1254
Lines 48665 48665
Branches 6845 6845
=================================================
- Hits 30519 30516 -3
- Misses 15471 15472 +1
- Partials 2675 2677 +2 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #1995 to
wicket-11.x, for GitHub issue #1943.VeilPageSeleniumTestpresses the keys for real and can drive Firefox.No API change, nothing to migrate. Under a veil, Enter and Space no longer reach covered elements until it is lowered.
Verified on this branch:
mvn clean verify -Pjs-testis green, japicmp included.This goes in after #1995. If #1995 changes in review, this branch gets the same change.