Loading ...
Sorry, an error occurred while loading the content.
 

Autocomplete: canceling a match with keyboard only

Expand Messages
  • jessekeller
    I ve got an autocompleter with forceSelection:false. The user types in ban . The autocompleter queries on ban , and comes up with banana , band and
    Message 1 of 3 , May 24, 2006
      I've got an autocompleter with forceSelection:false.

      The user types in "ban". The autocompleter queries on "ban", and comes
      up with "banana", "band" and "bank".

      But the user actually wants to enter the word "ban".

      As far as I can tell, the only way to collapse the autocomplete panel
      without selecting one of the query results is to click on some other
      part of the page. Is there any way to do it using the keyboard only?

      - pressing tab to move to the next form field automatically selects
      the first query result, "banana".

      - pressing return selects "banana"

      - pressing escape closes the autocomplete panel, but in IE, it also
      clears the input textbox
    • jennykhan
      Hi Jesse, This is a feature enhancement that I d love to add. If you can submit it via SourceForge, we can track it there. Thanks for the great feedback, Jenny
      Message 2 of 3 , May 24, 2006
        Hi Jesse,

        This is a feature enhancement that I'd love to add. If you can submit
        it via SourceForge, we can track it there.

        Thanks for the great feedback,
        Jenny




        --- In ydn-javascript@yahoogroups.com, "jessekeller" <jessekeller@...>
        wrote:
        >
        > I've got an autocompleter with forceSelection:false.
        >
        > The user types in "ban". The autocompleter queries on "ban", and comes
        > up with "banana", "band" and "bank".
        >
        > But the user actually wants to enter the word "ban".
        >
        > As far as I can tell, the only way to collapse the autocomplete panel
        > without selecting one of the query results is to click on some other
        > part of the page. Is there any way to do it using the keyboard only?
        >
        > - pressing tab to move to the next form field automatically selects
        > the first query result, "banana".
        >
        > - pressing return selects "banana"
        >
        > - pressing escape closes the autocomplete panel, but in IE, it also
        > clears the input textbox
        >
      • Michał Frąckowiak
        Hi, Indeed it is the feature I miss a lot. So here is a quick way how to implement it (I hope this will be in the next release): near line 210 insert the code:
        Message 3 of 3 , May 25, 2006
          Hi,

          Indeed it is the feature I miss a lot. So here is a quick way how to
          implement it (I hope this will be in the next release):

          near line 210 insert the code:

          /**
          * Whether or not to select the first item when activating and populating
          * the list from query results.
          *
          * @type boolean
          */

          YAHOO.widget.AutoComplete.prototype.selectFirstItem = true;

          also modify the lines near 1200 and replace the block:

          // Select first item and show UI
          var oFirstItem = document.getElementById(aItems[0]);
          oSelf._toggleHighlight(oFirstItem,'mouseover');
          oSelf._toggleContainer(true);
          oSelf.itemArrowToEvent.fire(oSelf, oFirstItem);
          //YAHOO.log(oSelf.getName() + " arrowed to item " + oFirstItem.id);
          oSelf._typeAhead(oFirstItem,sQuery);
          oSelf._oCurItem = oFirstItem;

          with the modified version:

          // Select first item (if configured to) and show UI
          oSelf._toggleContainer(true);

          if(oSelf.selectFirstItem == true){
          var oFirstItem = document.getElementById(aItems[0]);
          oSelf._toggleHighlight(oFirstItem,'mouseover');
          oSelf.itemArrowToEvent.fire(oSelf, oFirstItem);
          oSelf._oCurItem = oFirstItem;
          oSelf._typeAhead(oFirstItem,sQuery);
          }

          now in your code simply add the line:

          myAutoComp.selectFirstItem = false;

          And here you go! Although I have followed the flow I have not tested
          this piece of code a lot. It works however in several places in my
          project without any problems.

          best regards - michal frackowiak



          --- In ydn-javascript@yahoogroups.com, "jennykhan" <jennyhan@...> wrote:
          >
          > Hi Jesse,
          >
          > This is a feature enhancement that I'd love to add. If you can submit
          > it via SourceForge, we can track it there.
          >
          > Thanks for the great feedback,
          > Jenny
          >
          >
          >
          >
          > --- In ydn-javascript@yahoogroups.com, "jessekeller" <jessekeller@>
          > wrote:
          > >
          > > I've got an autocompleter with forceSelection:false.
          > >
          > > The user types in "ban". The autocompleter queries on "ban", and comes
          > > up with "banana", "band" and "bank".
          > >
          > > But the user actually wants to enter the word "ban".
          > >
          > > As far as I can tell, the only way to collapse the autocomplete panel
          > > without selecting one of the query results is to click on some other
          > > part of the page. Is there any way to do it using the keyboard only?
          > >
          > > - pressing tab to move to the next form field automatically selects
          > > the first query result, "banana".
          > >
          > > - pressing return selects "banana"
          > >
          > > - pressing escape closes the autocomplete panel, but in IE, it also
          > > clears the input textbox
          > >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.