emoji-picker-react 4.20.5 → 4.20.7
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/emoji-picker-react.cjs.development.js +55 -33
- 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 +55 -33
- package/dist/emoji-picker-react.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/body/EmojiList.tsx +16 -4
- package/src/hooks/useSetVariationPicker.ts +17 -2
package/package.json
CHANGED
|
@@ -34,12 +34,12 @@ export function EmojiList({ scrollTop }: { scrollTop: number }) {
|
|
|
34
34
|
// native button role for activation semantics.
|
|
35
35
|
// https://github.com/ealush/emoji-picker-react/issues/508
|
|
36
36
|
// The list markup is kept for a backwards-compatible DOM structure;
|
|
37
|
-
// the grid role override is intentional
|
|
38
|
-
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
|
|
37
|
+
// the grid role override is intentional.
|
|
39
38
|
return (
|
|
39
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
|
|
40
40
|
<ul className={cx(styles.emojiList)} ref={EmojiListRef} role="grid">
|
|
41
41
|
<MeasureEmoji />
|
|
42
|
-
{categories.map((categoryConfig) => {
|
|
42
|
+
{categories.map((categoryConfig, index) => {
|
|
43
43
|
const category = categoryFromCategoryConfig(categoryConfig);
|
|
44
44
|
|
|
45
45
|
const currentOffset = topOffset;
|
|
@@ -54,6 +54,7 @@ export function EmojiList({ scrollTop }: { scrollTop: number }) {
|
|
|
54
54
|
categoryEmojis={getEmojisByCategory(category)}
|
|
55
55
|
categoryConfig={categoryConfig}
|
|
56
56
|
topOffset={currentOffset}
|
|
57
|
+
isFirstCategory={index === 0}
|
|
57
58
|
onHeightReady={(height) => {
|
|
58
59
|
if (categoryHeights[category] !== height) {
|
|
59
60
|
setCategoryHeights((prev) => ({
|
|
@@ -76,21 +77,32 @@ function RenderCategory({
|
|
|
76
77
|
topOffset,
|
|
77
78
|
onHeightReady,
|
|
78
79
|
scrollTop,
|
|
80
|
+
isFirstCategory,
|
|
79
81
|
}: {
|
|
80
82
|
categoryEmojis: DataEmojis;
|
|
81
83
|
categoryConfig: CategoryConfig;
|
|
82
84
|
topOffset: number;
|
|
83
85
|
onHeightReady: (height: number) => void;
|
|
84
86
|
scrollTop: number;
|
|
87
|
+
isFirstCategory: boolean;
|
|
85
88
|
}) {
|
|
86
89
|
const [visibleCategories] = useVisibleCategoriesState();
|
|
87
90
|
|
|
91
|
+
// The observer is the only writer of visibleCategories. When it never
|
|
92
|
+
// fires (zero-height container at mount, hidden modal), no category
|
|
93
|
+
// would ever render. The first category paints optimistically to break
|
|
94
|
+
// the deadlock; the observer takes over from there.
|
|
95
|
+
// https://github.com/ealush/emoji-picker-react/issues/469
|
|
96
|
+
// https://github.com/ealush/emoji-picker-react/issues/475
|
|
97
|
+
const isCategoryVisible =
|
|
98
|
+
isFirstCategory || visibleCategories.includes(categoryConfig.category);
|
|
99
|
+
|
|
88
100
|
const { virtualizedCounter, emojis, dimensions } = useEmojiVirtualization({
|
|
89
101
|
categoryEmojis,
|
|
90
102
|
topOffset,
|
|
91
103
|
onHeightReady,
|
|
92
104
|
scrollTop,
|
|
93
|
-
isCategoryVisible
|
|
105
|
+
isCategoryVisible,
|
|
94
106
|
});
|
|
95
107
|
|
|
96
108
|
return (
|
|
@@ -1,13 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
allUnifiedFromEmojiElement,
|
|
3
|
+
NullableElement,
|
|
4
|
+
} from '../DomUtils/selectors';
|
|
2
5
|
import { useSetAnchoredEmojiRef } from '../components/context/ElementRefContext';
|
|
3
6
|
import { useEmojiVariationPickerState } from '../components/context/PickerContext';
|
|
7
|
+
import { usePickerDataContext } from '../components/context/PickerDataContext';
|
|
4
8
|
|
|
5
9
|
export default function useSetVariationPicker() {
|
|
6
10
|
const setAnchoredEmojiRef = useSetAnchoredEmojiRef();
|
|
7
11
|
const [, setEmojiVariationPicker] = useEmojiVariationPickerState();
|
|
12
|
+
// Context-aware lookup: respects the `emojiData` prop (e.g. translations).
|
|
13
|
+
// The legacy global lookup only knows the default English dataset.
|
|
14
|
+
// https://github.com/ealush/emoji-picker-react/issues/503
|
|
15
|
+
const { emojiByUnified } = usePickerDataContext();
|
|
8
16
|
|
|
9
17
|
return function setVariationPicker(element: NullableElement) {
|
|
10
|
-
const
|
|
18
|
+
const { unified, originalUnified } = allUnifiedFromEmojiElement(element);
|
|
19
|
+
const resolvedUnified = unified ?? originalUnified;
|
|
20
|
+
|
|
21
|
+
if (!resolvedUnified) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const emoji = emojiByUnified(resolvedUnified);
|
|
11
26
|
|
|
12
27
|
if (emoji) {
|
|
13
28
|
setAnchoredEmojiRef(element);
|