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

Đang mở
#1,943 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
74/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java, javascript
Lĩnh vực
accessibility, frontend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Java
Star
800
Fork
437
Merge trung bình
21 giờ 36 phút
Pull request đã merge (30 ngày)
167

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/wicket

Tất cả issue của apache/wicket

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.