emoji-picker-react 4.7.16 → 4.7.18

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.7.16",
2
+ "version": "4.7.18",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -87,25 +87,8 @@ export function useEmojiPreviewEvents(
87
87
  if (button) {
88
88
  const belowFoldByPx = detectEmojyPartiallyBelowFold(button, bodyRef);
89
89
  const buttonHeight = button.getBoundingClientRect().height;
90
- if (belowFoldByPx < buttonHeight / 2) {
91
- const { unified, originalUnified } = allUnifiedFromEmojiElement(
92
- button
93
- );
94
-
95
- if (!unified || !originalUnified) {
96
- return;
97
- }
98
-
99
- setPreviewEmoji({
100
- unified,
101
- originalUnified
102
- });
103
-
104
- return;
105
- }
106
90
  if (belowFoldByPx < buttonHeight) {
107
- button.scrollIntoView({ behavior: 'smooth', block: 'end' });
108
- return;
91
+ return handlePartiallyVisibleElementFocus(button, setPreviewEmoji);
109
92
  }
110
93
 
111
94
  focusElement(button);
@@ -121,3 +104,21 @@ export function useEmojiPreviewEvents(
121
104
  };
122
105
  }, [BodyRef, allow, setPreviewEmoji, isMouseDisallowed, allowMouseMove]);
123
106
  }
107
+
108
+ function handlePartiallyVisibleElementFocus(
109
+ button: HTMLElement,
110
+ setPreviewEmoji: React.Dispatch<React.SetStateAction<PreviewEmoji>>
111
+ ) {
112
+ const { unified, originalUnified } = allUnifiedFromEmojiElement(button);
113
+
114
+ if (!unified || !originalUnified) {
115
+ return;
116
+ }
117
+
118
+ (document.activeElement as HTMLElement)?.blur?.();
119
+
120
+ setPreviewEmoji({
121
+ unified,
122
+ originalUnified
123
+ });
124
+ }