emoji-picker-react 4.7.15 → 4.7.16
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/dist/DomUtils/selectors.d.ts +4 -0
- package/dist/emoji-picker-react.cjs.development.js +25 -2
- package/dist/emoji-picker-react.cjs.development.js.map +1 -1
- package/dist/emoji-picker-react.cjs.production.min.js +1 -1
- package/dist/emoji-picker-react.cjs.production.min.js.map +1 -1
- package/dist/emoji-picker-react.esm.js +25 -2
- package/dist/emoji-picker-react.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/DomUtils/selectors.ts +16 -0
- package/src/hooks/useEmojiPreviewEvents.ts +16 -5
package/package.json
CHANGED
|
@@ -166,6 +166,22 @@ export function originalUnifiedFromEmojiElement(
|
|
|
166
166
|
return null;
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
export function allUnifiedFromEmojiElement(
|
|
170
|
+
emoji: NullableElement
|
|
171
|
+
): { unified: string | null; originalUnified: string | null } {
|
|
172
|
+
if (!emoji) {
|
|
173
|
+
return {
|
|
174
|
+
unified: null,
|
|
175
|
+
originalUnified: null
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return {
|
|
180
|
+
unified: unifiedFromEmojiElement(emoji),
|
|
181
|
+
originalUnified: originalUnifiedFromEmojiElement(emoji)
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
|
|
169
185
|
function elementDataSetKey(
|
|
170
186
|
element: NullableElement,
|
|
171
187
|
key: string
|
|
@@ -4,9 +4,8 @@ import { useEffect } from 'react';
|
|
|
4
4
|
import { detectEmojyPartiallyBelowFold } from '../DomUtils/detectEmojyPartiallyBelowFold';
|
|
5
5
|
import { focusElement } from '../DomUtils/focusElement';
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
unifiedFromEmojiElement
|
|
7
|
+
allUnifiedFromEmojiElement,
|
|
8
|
+
buttonFromTarget
|
|
10
9
|
} from '../DomUtils/selectors';
|
|
11
10
|
import { useBodyRef } from '../components/context/ElementRefContext';
|
|
12
11
|
import { PreviewEmoji } from '../components/footer/Preview';
|
|
@@ -50,8 +49,7 @@ export function useEmojiPreviewEvents(
|
|
|
50
49
|
return onLeave();
|
|
51
50
|
}
|
|
52
51
|
|
|
53
|
-
const unified =
|
|
54
|
-
const originalUnified = originalUnifiedFromEmojiElement(button);
|
|
52
|
+
const { unified, originalUnified } = allUnifiedFromEmojiElement(button);
|
|
55
53
|
|
|
56
54
|
if (!unified || !originalUnified) {
|
|
57
55
|
return onLeave();
|
|
@@ -90,6 +88,19 @@ export function useEmojiPreviewEvents(
|
|
|
90
88
|
const belowFoldByPx = detectEmojyPartiallyBelowFold(button, bodyRef);
|
|
91
89
|
const buttonHeight = button.getBoundingClientRect().height;
|
|
92
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
|
+
|
|
93
104
|
return;
|
|
94
105
|
}
|
|
95
106
|
if (belowFoldByPx < buttonHeight) {
|