You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Martin Tzvetanov Grigorov (Jira)" <ji...@apache.org> on 2022/08/22 07:42:00 UTC

[jira] [Commented] (WICKET-6997) OnChangeAjaxBehavior blocks first subsequent button click

    [ https://issues.apache.org/jira/browse/WICKET-6997?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17582789#comment-17582789 ] 

Martin Tzvetanov Grigorov commented on WICKET-6997:
---------------------------------------------------

A simple workaround to your app is to not add the button to the AjaxRequestTarget if the button is already (in)visible.

 

The actual problem is that when you click the button the first even that is fired by the browser is `blur` on the input field, then the Ajax response removes the old/current/visible button and adds a new (again visible) one. Then the queued click event is discarded because its DOM element (the old button) is no more in the DOM document.

> 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)