Fixing search results click bug
Cause of the bug -
When clicking a search result, the selectSubject
action was being triggered twice.
- Once by the onClick method on the list item, which is expected,
- and once by the computed method
subjects
.
The reasoning behind the 2nd dispatch method is to automatically select the first item after a search is done. But the conditions used were not sufficient to distinguish a search, and so it was being triggered even when the list item was being clicked.
Solution - Adding a state variable in the store to accurately identify the search finished event and trigger the selection of the first item.