Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-6997

OnChangeAjaxBehavior blocks first subsequent button click

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Not A Problem
    • 9.11.0
    • None
    • wicket-core
    • None
    • - 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

    Description

      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:

      {
        "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
      }
      

      But the actual click event seems to be lost.

      After that, the next button click triggers the "click" event as expected:

      {
        "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
      }
      

      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.

       

      Attachments

        1. quickstart.zip
          29 kB
          Lars Mallinckrodt

        Activity

          People

            svenmeier Sven Meier
            lars_m Lars Mallinckrodt
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: