[ 
https://issues.apache.org/jira/browse/WICKET-6997?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Sven Meier closed WICKET-6997.
------------------------------
      Assignee: Sven Meier
    Resolution: Not A Problem

This is a known problem with OnChangeAjaxBehavior and browser event. To quote 
from OnChangeAjaxBehavior's javadoc:
{code:java}
* <strong>Note</strong>: JavaScript <em>change</em> event is being fired by the 
browser
* also when the HTML form element losses the focus, i.e. an Ajax call will be 
made even
* if there is no actual change of the form element's value!{code}
So just use an new AjaxFormComponentUpdatingBehavior("input") instead.

> OnChangeAjaxBehavior blocks first subsequent button click
> ---------------------------------------------------------
>
>                 Key: WICKET-6997
>                 URL: https://issues.apache.org/jira/browse/WICKET-6997
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket-core
>    Affects Versions: 9.11.0
>         Environment: - macOS 12.5.1 (intel)
> - Tomcat 8.5.82
> - OpenJDK Runtime Environment Temurin-11.0.16+8 (build 11.0.16+8)
> - Wicket 9.11.0
> - Firefox 103.0.2, Chrome 104.0.5112.101
>            Reporter: Lars Mallinckrodt
>            Assignee: Sven Meier
>            Priority: Minor
>         Attachments: quickstart.zip
>
>
> I have a simple form with a TextField and an AjaxButton. The button is 
> disabled initially and is being enabled after typing something in the 
> TextField using an OnChangeAjaxBehavior (see attached quickstart). Enabling 
> the button works as expected.
> However, when clicking on the button after the OnChangeAjaxBehavior has 
> fired, the first click is ignored. It is only after a second click on the 
> button that the onSubmit() method is triggered.
> Looking at the JS console, it seems that the first click triggers another 
> "input change" event due to the focus change:
> {code:json}
> {
>   "u": "./?3-1.0-form-input",
>   "m": "POST",
>   "c": "inputd",
>   "e": [
>     "input change"
>   ],
>   "event": {
>     "originalEvent": {
>       "isTrusted": true
>     },
>     "type": "change",
>     "target": {},
>     "currentTarget": {},
>     "timeStamp": 4471,
>     "jQuery360038239900837477336": true,
>     "delegateTarget": {},
>     "handleObj": {
>       "type": "change",
>       "origType": "change",
>       "data": null,
>       "guid": 4,
>       "namespace": ""
>     },
>     "data": null
>   },
>   "ch": "0|s",
>   "wr": true,
>   "dt": "xml",
>   "async": true,
>   "rt": 0,
>   "pd": false,
>   "sp": "bubble",
>   "sr": false
> }
> {code}
> But the actual click event seems to be lost.
> After that, the next button click triggers the "click" event as expected:
> {code:json}
> {
>   "u": "./?3-1.0-form-submit",
>   "m": "POST",
>   "c": "submit10",
>   "f": "forme",
>   "sc": "p::submit",
>   "e": [
>     "click"
>   ],
>   "pd": true,
>   "event": {
>     "originalEvent": {
>       "isTrusted": true
>     },
>     "type": "click",
>     "target": {},
>     "currentTarget": {},
>     "relatedTarget": null,
>     "timeStamp": 28490,
>     "jQuery360038239900837477336": true,
>     "delegateTarget": {},
>     "handleObj": {
>       "type": "click",
>       "origType": "click",
>       "data": null,
>       "guid": 62,
>       "namespace": ""
>     },
>     "data": null
>   },
>   "ch": "0|s",
>   "wr": true,
>   "dt": "xml",
>   "async": true,
>   "rt": 0,
>   "sp": "bubble",
>   "sr": false
> }
> {code}
> It should be noted that the bug does not occur when you tab out of the 
> TextField first. With the focus change out of the way, the first button click 
> directly works as expected.
> Also, parent component AjaxFormComponentUpdatingBehavior does not seem to be 
> affected by this bug.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to