Wicket
  1. Wicket
  2. WICKET-4857

AutoCompleteTextFields submits Form if a choice is selected via enter-key

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 6.0.0, 6.1.0, 6.1.1, 6.2.0
    • Fix Version/s: 6.3.0
    • Component/s: wicket-extensions
    • Labels:
      None

      Description

      I am not quite sure if this is really a bug, but the behaivor of wicket 1.5 and wicket 6 differs in the following situation:

      In wicket 1.5 a user could select a choice in an AutoCompleteTextField via the enter-key and the underlying Form was not submitted.
      In wicket 6 however the Form gets submitted in that case.

      Note: the behaivor is in both versions identical (aka no form submit) if no button is added to the form. Thus in both versions the Form is not submitted if the user selects a choice via mouse-click.

      While in some use cases it is useful that hitting the enter-key in TextFields submits the form - e.g. in a search panel, in this particular use case the form should not be submitted. Or at least, there should be a (built in) hook to prevent this behaivor.

      1. myproject-6.2.0.zip
        36 kB
        Marcel Hoerr
      2. myproject-1.5.zip
        38 kB
        Marcel Hoerr

        Issue Links

          Activity

          Hide
          Marcel Hoerr added a comment -

          quickstarts for wicket 1.5 and wicket 6 added.

          Show
          Marcel Hoerr added a comment - quickstarts for wicket 1.5 and wicket 6 added.
          Hide
          Andrea Del Bene added a comment - - edited

          Returning false instead of jqEvent.stopPropagation() at line 230 (file wiket-autocomplete.js) solves the problem. Alternatively we can add method jqEvent.preventDefault()

          Show
          Andrea Del Bene added a comment - - edited Returning false instead of jqEvent.stopPropagation() at line 230 (file wiket-autocomplete.js) solves the problem. Alternatively we can add method jqEvent.preventDefault()
          Hide
          Andrea Del Bene added a comment -
          Show
          Andrea Del Bene added a comment - Ok, this post contains a sort of explanation. http://stackoverflow.com/questions/1357118/event-preventdefault-vs-return-false
          Hide
          Martin Grigorov added a comment -

          Thanks Andrea!

          Show
          Martin Grigorov added a comment - Thanks Andrea!
          Hide
          Marcel Hoerr added a comment -

          Thanks!

          Show
          Marcel Hoerr added a comment - Thanks!
          Hide
          Mitesh Patel added a comment -

          Encounter this bug recently and I am using Wicket 6.6.0. I can reproduce this in 6.6.0.

          Tested Marcel's both quickstart with 6.3.0 and 6.6.0.

          Noticed for 6.3.0 and 6.6.0:-

          1) Selecting AutoCompleteTextFields via enter-key fill input box with selected item and it do not submits( AjaxButton's onSubmit method is called) form but cursor focus is in same input box and now if you press enter-key it submit form

          2) Click in AutoCompleteTextFields and just press enter-key still submits form.

          3) For TextField enter-key press, form is still getting submitted

          I apologizes if this is not place for above comment as this issue is already closed or these use cases are not valid for this issue

          Show
          Mitesh Patel added a comment - Encounter this bug recently and I am using Wicket 6.6.0. I can reproduce this in 6.6.0. Tested Marcel's both quickstart with 6.3.0 and 6.6.0. Noticed for 6.3.0 and 6.6.0:- 1) Selecting AutoCompleteTextFields via enter-key fill input box with selected item and it do not submits( AjaxButton's onSubmit method is called) form but cursor focus is in same input box and now if you press enter-key it submit form 2) Click in AutoCompleteTextFields and just press enter-key still submits form. 3) For TextField enter-key press, form is still getting submitted I apologizes if this is not place for above comment as this issue is already closed or these use cases are not valid for this issue
          Hide
          Sven Meier added a comment -

          Autocomplete has been continuously improved for Wicket 6.x, the latest fixed is for WICKET-5055. Could you try out Wicket trunk, and if you still experience a problem please open a new issue.

          Please double check the old behavior, e.g. 2) submits the form in 1.5.x too.

          Show
          Sven Meier added a comment - Autocomplete has been continuously improved for Wicket 6.x, the latest fixed is for WICKET-5055 . Could you try out Wicket trunk, and if you still experience a problem please open a new issue. Please double check the old behavior, e.g. 2) submits the form in 1.5.x too.
          Hide
          Mitesh Patel added a comment -

          I tested with 6.7.0-SNAPSHOT and behavior was same so I created new issue WICKET-5064

          Show
          Mitesh Patel added a comment - I tested with 6.7.0-SNAPSHOT and behavior was same so I created new issue WICKET-5064

            People

            • Assignee:
              Martin Grigorov
              Reporter:
              Marcel Hoerr
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development