dashorst opened a new issue, #1947:
URL: https://github.com/apache/wicket/issues/1947
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`:
```js
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](https://issues.apache.org/jira/browse/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](https://wicket.apache.org/contribute/wicket-pull-request.html) for
building and testing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]