PageVeilBehavior: Enter or Space pressed twice on a focused button sends two requests

オープン
#1,943 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
74/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java, javascript

調査の方向性

Start by reading wicket-veil.js and the PageVeilBehavior and LocalVeilBehavior implementations named in the issue. Trace how the page and local veils handle keyboard events, then check the existing tests for those behaviors. Done means repeated Enter or Space presses on covered controls do not send duplicate requests, while text entry, editable content, and IME composition remain unaffected.

索引モデルが issue の本文から書いたものです。

説明

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

What happens

A page with PageVeilBehavior and a form with an AjaxButton whose onSubmit takes a while:

add(new PageVeilBehavior());
form.add(new AjaxButton("save") {
    @Override
    protected void onSubmit(AjaxRequestTarget target) {
        runs.incrementAndGet();
        Thread.sleep(2000); // a slow action
    }
});

Focus Save with Tab, press Enter, and press Enter again before the answer comes. onSubmit runs twice. Space pressed twice does the same. Clicking twice with the mouse runs it once, as expected.

Checked with real key presses through WebDriver in Chrome 155 and Firefox 124.

Cause

The veil is a transparent div over the page, and it blocks only the mouse; wicket-veil.js says so itself. The focus stays on the button under the veil, so the second key press activates it. Its request waits on channel 0 and is sent once the first one is done.

Fix proposed

While a veil covers an element, drop the keydown (and its keyup) of Enter and Space whose target it covers:

  • for the page veil, any element;
  • for a local veil, the elements inside its host.

Leave alone the keys that type text:

  • Space in text inputs and selects;
  • Enter in a textarea or editable content;
  • keys during IME composition.

Making the content inert would also block the keyboard. But the page veil is a child of body, so inert would have to go on every other child of body, and it takes the focus away and hides the content from assistive technologies while it lasts.

Workaround

A capturing keydown listener of the application's own, which checks whether a .wicket-veil is in the page.

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

主要言語
Java
スター
800
フォーク
437
平均マージ
21時間 36分
マージ済み PR(30日)
167

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/wicket のほかの issue

apache/wicket の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。