-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lazy loading of values does not work second time around #44
Comments
Hold off on looking at this. I just came in this morning to do a bit more research on this, and I can no longer reproduce it. I'll follow up with some more information shortly. |
So what I am seeing is that after I use the suggest box a second time, the first request calls the suggest callback with a page parameter of 1, but the second request is whatever the maximum page was the last time around. So for example, if I click then scroll down and get page=1, then page=2 passed to the callback, then mouse out, and back in and click on the values box again, then start scrolling down, the second time, I get page=1 passed to the suggest callback, but then the next call to suggest has page=3. Also if I keep scrolling to the end, it keeps incrementing the page even though zero records have been returned. Question: Is there something else I need to pass besides an empty array to the callback to tell it there are no more rows for this suggest? |
I did some more testing and here is a walk-through of what I am seeing passed into my suggest callback from RQB. My suggest handler is something like: suggest(args,callback) { /* ajax call and other stuff when ajax is returned, I call callback(a) where a is an array of strings to populate the dropdown with */ } The behavior I am seeing is as follows: I select a field/column, then I click on the values box. I get the dropdown and I get a call to my suggest function with the following being passed in from RQB: columnName:"Contact_City_Output" Inside my suggest function, my ajax call returns and on success calls the "callback" function passed in and passes an array of string (20 items). I then scroll down until I get to the bottom of the dropdown so it fires suggest again. I then scroll down some more until I hit the bottom of the dropdown and it fires my suggest again, I get the same as above, except page:2 One more scroll give me page:3 I then click outside of the suggest box/defocus and the dropdown goes away. I click back in the suggest box and I get the same as the above with page:0 I then scroll down some more until I hit the bottom of the dropdown and it fires the suggest but this time it passes page:4. So it appears that what is happening is it works fine, until you defocus, then click back in the suggest box. When you click back in the suggest box, after a de-focus, it first fires with page:0, then when you scroll down, the second and subsequent calls to suggest set the page to the highest page that was previously accessed +1 and increments from there. In the above example if I keep scrolling, I get page:4, page:5, etc and it skips 1, 2 and 3, so I get passed pages 0,1,2,3,4 the first time, then after the defocus then focus and scroll I get pages 0,5,6,7 and it keeps going up. If I got up to page 7, then defocus/focus, next time I get pages 0,8,9,10 |
OK I think I have a fix for this one. It may not be elegant, but it seems to fix the problem. I reset the page variable when we get a blur even on the suggestbox. The patch is to add a line to the file: ./redquerybuilder-core/src/main/java/com/redspr/redquerybuilder/core/client/expression/SuggestEditorWidget.java After line 306 after the line: active = false; The full function before: suggestBox.getValueBox().addBlurHandler(new BlurHandler() {
@Override
public void onBlur(BlurEvent event) {
active = false;
}
}); The full function after: suggestBox.getValueBox().addBlurHandler(new BlurHandler() {
@Override
public void onBlur(BlurEvent event) {
active = false;
scrollDisplay.page = 0;
}
}); |
This is a bug on the Tardis branch to reproduce use the following steps:
If you do not first enter a value then click on the value box you get the suggest list, then scrolling to the bottom triggers the lazy load.
The text was updated successfully, but these errors were encountered: