fracht / rchat

Awesome react chat library.
MIT License
2 stars 2 forks source link

Unable to `unfocus` focused item when clearing search results. #203

Closed AlexShukel closed 2 months ago

AlexShukel commented 9 months ago

Describe the bug There is a problem with focusItem functionality in useMessages hook - when receiving empty search results and trying to focus undefined item - the state doesn't change and old focused item is still being focused.

To Reproduce Steps to reproduce the behavior:

  1. Set some search result.
  2. See that the first search result is being focused.
  3. Set search result to empty array.
  4. See that previously focused item is still being focused.

Expected behavior It is expected to unfocus that item.

Possible solution Function focusItem should rerender when receiving undefined item and an old focused item existed.