• Mark Florian's avatar
    Simplify clear logic for filtered search bar root · 301f366e
    Mark Florian authored
    This changes the behaviour of the `FilteredSearchBarRoot` component
    slightly. Previously, the `onFilter` event would fire when the user
    pressed backspace repeatedly to clear all the tokens. This event usually
    triggers a search to be performed, either as a redirect or an async
    request.
    
    Now, under those circumstances, that event is *not* fired. In order for
    a user to initiate a new search when there are no search tokens, they
    must either:
    
    - Hit enter after removing all search tokens with backspace. This makes
      it more consistent with *adding* tokens: the search is only performed
      on hitting Enter.
    - Click the "clear" button in `GlFilteredSearch`. This behaviour hasn't
      changed.
    
    Without this commit, on visiting the Project Members page (and possibly
    others), it would immediately reload, repeatedly, making the page was
    unusable. Various tests also broke with uninformative `Net:ReadTimeout`
    errors from Selenium.
    
    It turned out this was due to some recent changes to `GlFilteredSearch`,
    particularly
    https://gitlab.com/gitlab-org/gitlab-ui/-/merge_requests/2732 and
    https://gitlab.com/gitlab-org/gitlab-ui/-/merge_requests/2736, which
    changed how and when `input` events are fired from `GlFilteredSearch`.
    
    In debugging this, I encountered and wrote up
    https://gitlab.com/gitlab-org/gitlab-ui/-/issues/1789, which I suspect
    is the reason why the `filterValue` watcher was written this way in the
    first place. That bug should be fixed soon, since in Chrome, backspacing
    to clear a segmented token removes focus from the search input, so
    hitting Enter does not initiate a new search. This works correctly in
    Firefox, however.
    301f366e
filtered_search_bar_root_spec.js 17.6 KB