Fix bug where internal query state is not changed

A previous patch solved the problem of preventing typeahead from triggering an additional request on user selection. But the patch missed to clean up internal state. This patch fixes that issue.