5 Replies Latest reply on May 14, 2007 7:04 AM by 1kaa

    SuggestionBox always displays

    1kaa

      The list of suggestions is always displayed, even if the user tabs out of the field. Is there a way to stop this behaviour, since if the user tabs out of the field, they've probably completed it and no longer need the suggestions.

      It used to behave 'correctly' in 3.0.0, it has been 'broken' in the latest snapshots I've tried, including the release candidate.

      Thanks.

        • 1. Re: SuggestionBox always displays

          I cannot reproduce this problem on my side. The suggestion box is always disappeared. When I press the tab while the suggestion box is up, the current value is inserted. Do I miss something?

          • 2. Re: SuggestionBox always displays
            1kaa

            Hi Sergey,

            Thanks for the reply. I've tried this with RC2 and still have a problem. Here is some more detail on this.

            I have a 6 char input field that, after 2 chars are input, pops up a suggestion box. If I type the more than 2 chars in and tab to another field on the form the suggestion box is still displayed.

            Here is the richfaces xml:

            <a4j:region id="supplierAjax">
             <h:column>
             <h:inputText id="supplierCode"
             value="#{viewForecastEDIHandler.supplierCode}" maxlength="6"
             size="6">
             </h:inputText>
             </h:column>
             <rich:suggestionbox id="supplierSuggest" for="supplierCode"
             suggestionAction="#{supplierSuggestHandler.autocompleteSupplier}"
             width="330" height="150" var="sc" minChars="2"
             requestDelay="500"
             ignoreDupResponses="true" fetchValue="#{sc.supplierCode}">
             <h:column>
             <h:outputText value="#{sc.supplierCode}: #{sc.companyName}" />
             </h:column>
             </rich:suggestionbox>
             </a4j:region>


            When I tab out of the 'supplierCode' field, the suggestion action is still running in the background and no suggestion box has been displayed yet. When the suggestion action completes, the suggestion box is displayed, even though the focus is no longer in the 'supplierCode' field.

            This problem affects other suggestion box fields on other screens also.

            Karl.

            • 3. Re: SuggestionBox always displays
              nbelaevski

              Karl,

              so you're having long-running suggestion action that pumps results back to browser when suggestion box has lost the focus thus causing unwanted suggestions appearance, aren't you?

              • 4. Re: SuggestionBox always displays
                1kaa

                 

                "nbelaevski" wrote:
                so you're having long-running suggestion action that pumps results back to browser when suggestion box has lost the focus thus causing unwanted suggestions appearance, aren't you?


                Correct. The suggestion box has not yet appeared before I tab out of the field. The time taken to retrieve the suggestions is no more than 2 seconds. (Actually retrieving the data takes about 250 ms, it just takes IE ages to render the pop-up. Same problem in Fierfox, but this is much quicker).

                I've tried different values of requestDelay and frequency, but nothing seems to make a difference, other than delay the pop-up. As stated in the initial post, this was not a problem in 3.0.0

                Ideally what I'd expect to happen is to set a requestDelay of 1000ms and if the field loses focus then the suggestionAction is not performed. This gives knowledgeable users the ability to enter data without a pop-up and less experienced users can wait in the field for a pop-up.

                Sergey says he cannot replicate this, can anyone else - or is there something weird in my setup?

                Thanks,

                Karl.

                • 5. Re: SuggestionBox always displays
                  1kaa

                  One way around the problem of the suggestion box displaying after the user has tabbed out, is to do the following:

                  . Use the onfocus/onblur handlers for the input field to set a flag true/false.
                  . Use the suggestionBox onsubmit handler to check/return the flag. If the flag is false, then the ajax request is not issued.


                  Works for me. Note that you'll have to set the requestDelay and frequency values to allow time to ensure the user has tabbed out of the field before the onsubmit request is issued.

                  I don't know if the original problem is a bug or a feature request.