Stop the autocomplete from accumulating request parameters while typing

Đang mở Phù hợp với người mới
#1,947 2 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

@aryankalantri đang làm issue này rồi.

Từ ngày 22/11/2026.

  • #1990 của @aryankalantri — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
88/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
frontend, web-dev

Hướng nghiên cứu

Bắt đầu tại wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js, trong prepareAndExecuteAjaxUpdate, và kiểm tra cách pre, sh và ep được sao chép trước khi các giá trị được thêm vào. Chạy StartExamples từ wicket-examples/src/test/java và mở org.apache.wicket.examples.ajax.builtin.AutoCompletePage; cấu hình một tham số bổ sung và kiểm tra công cụ dành cho nhà phát triển để xác nhận mỗi yêu cầu có một tham số truy vấn chứa nội dung nhập hiện tại.

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

Mô tả

good first issue

When an AutoCompleteTextField has extra Ajax attributes (for example a parameter added in updateAjaxAttributes), every keystroke adds another copy of the query parameter to the request. The parameter list keeps growing until the component is re-rendered, and AutoCompleteBehavior.getChoices(String) ends up receiving the first value that was typed instead of the current one.

Where

wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js, function prepareAndExecuteAjaxUpdate:

const attrs = Object.assign({}, ajaxAttributes);
...
attrs.pre = attrs.pre || [];
attrs.pre.push(...);
attrs.sh = attrs.sh || [];
attrs.sh.push(successHandler);
attrs.ep = attrs.ep || [];
attrs.ep.push({'name' : cfg.parameterName, 'value' : currentInput});

Object.assign makes a shallow copy. When ajaxAttributes already has pre, sh or ep arrays, attrs points at the same arrays, and each push modifies the shared original.

Done when

  • Each request carries the query parameter exactly once, with the current input, also when extra parameters are configured.
  • There are no JavaScript unit tests for the autocomplete yet. Verify the fix in the browser with the autocomplete example (wicket-examples, org.apache.wicket.examples.ajax.builtin.AutoCompletePage, started from StartExamples in wicket-examples/src/test/java) by adding an extra parameter and watching the requests in the developer tools. Describe what you checked in the pull request.

Background

Originally reported as WICKET-7130 (Wicket 9.18), with a quickstart attached to the Jira ticket.


Part of #1945. This issue is meant for a first contribution to Wicket. To work on it, leave a comment so others know; a claim without a pull request lapses after two weeks. Questions are welcome, here on the issue or on [email protected]. Start your branch from master, and see Send a pull request to Wicket for building and testing.

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.