Stop the autocomplete from accumulating request parameters while typing

Abierto Apto para principiantes
#1,947 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@aryankalantri ya está trabajando en esto.

Desde el 22/11/2026.

  • #1990 de @aryankalantri — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
88/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
java, javascript
Área
frontend, web-dev

Línea de trabajo

Empieza en wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js, en prepareAndExecuteAjaxUpdate, y comprueba cómo se copian pre, sh y ep antes de añadir valores. Ejecuta StartExamples desde wicket-examples/src/test/java y abre org.apache.wicket.examples.ajax.builtin.AutoCompletePage; configura un parámetro adicional y comprueba en las herramientas de desarrollo que cada solicitud tenga un parámetro de consulta con la entrada actual.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Java
Estrellas
800
Forks
437
Merge medio
21 h 36 min
PR fusionados (30 d)
167

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de apache/wicket

Todos los issues de apache/wicket

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.