emoji-picker-react 4.15.0 → 4.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.15.0",
2
+ "version": "4.15.1",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "homepage": "https://ealush.com/emoji-picker-react",
@@ -15,6 +15,7 @@ export function useActiveCategoryScrollDetection({
15
15
 
16
16
  useEffect(() => {
17
17
  const visibleCategories = new Map<string, number>();
18
+ const intersectingCategories = new Map<string, boolean>();
18
19
  const bodyRef = BodyRef.current;
19
20
  const observer = new IntersectionObserver(
20
21
  entries => {
@@ -30,15 +31,18 @@ export function useActiveCategoryScrollDetection({
30
31
  }
31
32
 
32
33
  visibleCategories.set(id, entry.intersectionRatio);
34
+ intersectingCategories.set(id, entry.isIntersecting);
33
35
  }
34
36
 
35
37
  const ratios = Array.from(visibleCategories);
36
- setVisibleCategories(
37
- ratios.filter(([_, ratio]) => ratio > 0).map(([id]) => id)
38
- );
38
+ const visibleCats = ratios
39
+ .filter(([id, ratio]) => ratio > 0 || intersectingCategories.get(id))
40
+ .map(([id]) => id);
41
+
42
+ setVisibleCategories(visibleCats);
39
43
  const lastCategory = ratios[ratios.length - 1];
40
44
 
41
- if (lastCategory[1] == 1) {
45
+ if (lastCategory?.[1] == 1) {
42
46
  return setActiveCategory(lastCategory[0]);
43
47
  }
44
48
 
@@ -50,11 +54,16 @@ export function useActiveCategoryScrollDetection({
50
54
  }
51
55
  },
52
56
  {
57
+ root: bodyRef,
53
58
  threshold: [0, 1]
54
59
  }
55
60
  );
56
61
  bodyRef?.querySelectorAll(asSelectors(ClassNames.category)).forEach(el => {
57
62
  observer.observe(el);
58
63
  });
64
+
65
+ return () => {
66
+ observer.disconnect();
67
+ };
59
68
  }, [BodyRef, setActiveCategory, setVisibleCategories]);
60
69
  }