rn-emoji-keyboard icon indicating copy to clipboard operation
rn-emoji-keyboard copied to clipboard

fix: infinite loop on category swipe

Open AnMiZa opened this issue 1 year ago • 4 comments

This PR fixes infinite loop on quick emoji list scroll behavior reported in issue https://github.com/TheWidlarzGroup/rn-emoji-keyboard/issues/159

Changes:

  • moved logic for scrolling emoji categories from useEffect hook to separate method
  • passed said method into handleScrollToCategory method in Categories component and into SearchBar component to handle EmojiCategory list scrolling from children

In the previous implementation, after scrolling between EmojiCategories using gesture, when setActiveCategory was called inside onScrollEnd method, useEffect callback with scrollToIndex was fired with activeCategoryIndex that the list was already at. Quick scrolling back and forth with gesture was causing infinite state updates between current and previous activeCategoryIndexes. To fix that behavior while leaving ability to browse EmojiCategories using CategoryItem press scrollToIndex is now called directly inside CategoryItem

AnMiZa avatar Feb 04 '24 14:02 AnMiZa

@AnMiZa when you tap the search bar, does the list scroll to the search at the end? in my case it won't scroll after applying this pr.

efstathiosntonas avatar Feb 06 '24 21:02 efstathiosntonas

Hey, @efstathiosntonas great catch! I was not aware of that functionality so I did not refactor it. I also had this loop bug when I was checking it out on master just now. Thanks for pointing that out, I will fix it tomorrow. I'll convert this PR to draft until then @jakex7.

AnMiZa avatar Feb 06 '24 21:02 AnMiZa

@efstathiosntonas everything should work as intended now. Check it out.

AnMiZa avatar Feb 07 '24 08:02 AnMiZa

@AnMiZa works as a charm. Thank you for jumping so fast in this and for this PR overall!

efstathiosntonas avatar Feb 07 '24 09:02 efstathiosntonas

I'm also experiencing this and I'm glad that is already fixed, thank you so much 🙌

When is the next version going to be released?

focux avatar Mar 27 '24 15:03 focux