autocomplete icon indicating copy to clipboard operation
autocomplete copied to clipboard

onSelect item should trigger store.pendingRequests.cancelAll();

Open AntoineDuComptoirDesPharmacies opened this issue 8 months ago • 1 comments

Description

Following of this issue : #806, when we programatically call setIsOpen(false) to the Autocomplete instance, the current requests are not cancelled and the panel re-open when queries finish.

Reproduction

Preview →

Steps

  1. Go to the code sandbox
  2. Click on the Search and type 'd', wait for results to display
  3. Pass your browser network in slow mode
  4. Type 'deb' in the search bar and immediately select an item from the previous search (that will trigger a setIsOpen(false) + history.push to bring you to the item subpage)
  5. React router change the components of the user, the search is correctly closed
  6. As requests are not cancelled, when one finish, the autocomplete panel re-open

Expected behavior

When the autocomplete isOpen become false, all existing queries should be cancelled so the autocomplete panel re-open only if the input take focus again.

Environment

  • OS: Windows 10
  • Browser: Chrome
  • Autocomplete version: 1.11.1

I believe that redirects may rely on the request not being cancelled (at least available in the results), but it should indeed prevent to reopen though

Haroenv avatar Oct 18 '23 09:10 Haroenv