Fix GWT UI AddFileBox to provide path suggestions continuously

- How to reproduce the bug?
  In ChangeScreen, click 'Edit', then 'Add...'. Type in some text, you
  will get some path suggestions. Delete all the text you've typed in.
  There will be no suggestion any more until the page is reloaded.

- Why does this happen?
  The UI will continue create new query when the text box is focused
  and the 'query' is null in RemoteSuggestOracle. When the text box is
  cleared, it will result in a NullPointerException in
  RESTApi.addParameter(String, String) when it calls
  URL.encodeQueryString as the request.getQuery() is null. Once this
  exception happens, onSuggestionReady will not be called and 'query'
  field in RemoteSuggestOracle will not be reset to null. That's why
  the UI will not try new Request until the page is reloaded.

  This problem may be related to GWT 2.8 upgrade. It started behaving
  differently after the upgrade. However, I haven't noticed this
  problem for reviewers suggestion.

- Solution
  Set the query to be empty when request.getQuery() is null.

Bug: Issue 5365
Change-Id: Ia0878b67aebde854012e3cacec51d922a9f32919
This commit is contained in:
Changcheng Xiao 2017-02-16 13:48:30 +01:00
parent 3ae681fd6e
commit 15615078df

View File

@ -104,6 +104,9 @@ public class RemoteSuggestOracle extends SuggestOracle {
}
void start() {
if (request.getQuery() == null) {
request.setQuery("");
}
oracle.requestSuggestions(request, this);
}