Wicket
  1. Wicket
  2. WICKET-1827

AutoCompleteTextField shows completion list even if focus is not in the text field anymore

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.4
    • Fix Version/s: 1.3.5
    • Component/s: wicket-extensions
    • Labels:
      None
    • Environment:
      Ubuntu/Firefox 3.0.1, OS X/Safari 3.1.2, Win XP/IE6, Win XP/IE7

      Description

      We have a form with multiple AutoCompleteTextFields in it. If the user enters text in text field A, and moves focus to text field B immediately (within the throttle delay) e.g. using tab, the autocompletion list appears in text field A even though it doesn't have the focus anymore.

      Looking at wicket-autocomplete.js, the fix should be pretty straightforward, i.e. just check whether the input still has focus at the time when the autocompletion list is shown (in doUpdateChoices(resp)). This works for me:

      — wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js (revision 694678)
      +++ wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js (working copy)
      @@ -304,9 +304,9 @@

      function doUpdateChoices(resp){

      • // check if the input hasn't been cleared in the meanwhile
        + // check that the input still has focus and hasn't been cleared in the meanwhile
        var input=wicketGet(elementId);
      • if (!cfg.showListOnEmptyInput && (input.value==null || input.value=="")) {
        + if ((Wicket.Focus.getFocusedElement() != input) || (!cfg.showListOnEmptyInput && (input.value==null || input.value==""))) { hideAutoComplete(); return; }

        Activity

        Hide
        Jari Aarniala added a comment -

        typo

        Show
        Jari Aarniala added a comment - typo
        Hide
        Jari Aarniala added a comment - - edited

        Affects Wicket 1.3.4. Tested quickly with IE6/IE7, verified that the bug exists for both, and that the fix also works for both.

        Show
        Jari Aarniala added a comment - - edited Affects Wicket 1.3.4. Tested quickly with IE6/IE7, verified that the bug exists for both, and that the fix also works for both.
        Hide
        Johan Compagner added a comment -

        i still have to port this to 1.4 but it is fixed for 1.3.5

        Show
        Johan Compagner added a comment - i still have to port this to 1.4 but it is fixed for 1.3.5
        Hide
        Murat Yücel added a comment -

        Is there a workaround to get this fixed for 1.4?

        Show
        Murat Yücel added a comment - Is there a workaround to get this fixed for 1.4?

          People

          • Assignee:
            Johan Compagner
            Reporter:
            Jari Aarniala
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development