emoji-picker-react 4.9.0 → 4.9.2
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/elementPositionInRow.d.ts +1 -1
- package/dist/emoji-picker-react.cjs.development.js +28 -10
- 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 +28 -10
- package/dist/emoji-picker-react.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/DomUtils/elementPositionInRow.ts +27 -11
- package/src/DomUtils/scrollTo.ts +1 -1
- package/src/DomUtils/selectors.ts +1 -1
- package/src/components/emoji/ClickableEmojiButton.tsx +7 -1
package/package.json
CHANGED
|
@@ -143,7 +143,8 @@ export function getElementInPrevRow(
|
|
|
143
143
|
|
|
144
144
|
export function firstVisibleElementInContainer(
|
|
145
145
|
parent: NullableElement,
|
|
146
|
-
elements: HTMLElement[]
|
|
146
|
+
elements: HTMLElement[],
|
|
147
|
+
maxVisibilityDiffThreshold = 0
|
|
147
148
|
): NullableElement {
|
|
148
149
|
if (!parent || !elements.length) {
|
|
149
150
|
return null;
|
|
@@ -151,20 +152,27 @@ export function firstVisibleElementInContainer(
|
|
|
151
152
|
|
|
152
153
|
const parentTop = parent.getBoundingClientRect().top;
|
|
153
154
|
const parentBottom = parent.getBoundingClientRect().bottom;
|
|
154
|
-
|
|
155
|
-
const parentTopWithLabel = parentTop + getLabelHight(parent);
|
|
155
|
+
const parentTopWithLabel = parentTop + getLabelHeight(parent);
|
|
156
156
|
|
|
157
157
|
const visibleElements = elements.find(element => {
|
|
158
158
|
const elementTop = element.getBoundingClientRect().top;
|
|
159
159
|
const elementBottom = element.getBoundingClientRect().bottom;
|
|
160
|
+
const maxVisibilityDiffPixels =
|
|
161
|
+
element.clientHeight * maxVisibilityDiffThreshold;
|
|
160
162
|
|
|
161
|
-
|
|
163
|
+
const elementTopWithAllowedDiff = elementTop + maxVisibilityDiffPixels;
|
|
164
|
+
const elementBottomWithAllowedDiff =
|
|
165
|
+
elementBottom - maxVisibilityDiffPixels;
|
|
166
|
+
|
|
167
|
+
if (elementTopWithAllowedDiff < parentTopWithLabel) {
|
|
162
168
|
return false;
|
|
163
169
|
}
|
|
164
170
|
|
|
165
171
|
return (
|
|
166
|
-
(
|
|
167
|
-
|
|
172
|
+
(elementTopWithAllowedDiff >= parentTop &&
|
|
173
|
+
elementTopWithAllowedDiff <= parentBottom) ||
|
|
174
|
+
(elementBottomWithAllowedDiff >= parentTop &&
|
|
175
|
+
elementBottomWithAllowedDiff <= parentBottom)
|
|
168
176
|
);
|
|
169
177
|
});
|
|
170
178
|
|
|
@@ -175,10 +183,18 @@ export function hasNextElementSibling(element: HTMLElement) {
|
|
|
175
183
|
return !!element.nextElementSibling;
|
|
176
184
|
}
|
|
177
185
|
|
|
178
|
-
function
|
|
179
|
-
|
|
180
|
-
parentNode
|
|
181
|
-
.querySelector(asSelectors(ClassNames.label))
|
|
182
|
-
?.getBoundingClientRect().height ?? DEFAULT_LABEL_HEIGHT /* default */
|
|
186
|
+
function getLabelHeight(parentNode: HTMLElement) {
|
|
187
|
+
const labels = Array.from(
|
|
188
|
+
parentNode.querySelectorAll(asSelectors(ClassNames.label))
|
|
183
189
|
);
|
|
190
|
+
|
|
191
|
+
for (const label of labels) {
|
|
192
|
+
const height = label.getBoundingClientRect().height;
|
|
193
|
+
// return height if label is not hidden
|
|
194
|
+
if (height > 0) {
|
|
195
|
+
return height;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return DEFAULT_LABEL_HEIGHT;
|
|
184
200
|
}
|
package/src/DomUtils/scrollTo.ts
CHANGED
|
@@ -264,7 +264,7 @@ export function firstVisibleEmoji(parent: NullableElement) {
|
|
|
264
264
|
|
|
265
265
|
const allEmojis = allVisibleEmojis(parent);
|
|
266
266
|
|
|
267
|
-
return firstVisibleElementInContainer(parent, allEmojis);
|
|
267
|
+
return firstVisibleElementInContainer(parent, allEmojis, 0.1);
|
|
268
268
|
}
|
|
269
269
|
|
|
270
270
|
export function prevCategory(element: NullableElement): NullableElement {
|
|
@@ -46,7 +46,7 @@ export function ClickableEmojiButton({
|
|
|
46
46
|
className
|
|
47
47
|
)}
|
|
48
48
|
data-unified={unified}
|
|
49
|
-
aria-label={emojiNames
|
|
49
|
+
aria-label={getAriaLabel(emojiNames)}
|
|
50
50
|
data-full-name={emojiNames}
|
|
51
51
|
>
|
|
52
52
|
{children}
|
|
@@ -54,6 +54,12 @@ export function ClickableEmojiButton({
|
|
|
54
54
|
);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
function getAriaLabel(emojiNames: string[]) {
|
|
58
|
+
return emojiNames[0].match('flag-')
|
|
59
|
+
? emojiNames[1] ?? emojiNames[0]
|
|
60
|
+
: emojiNames[0];
|
|
61
|
+
}
|
|
62
|
+
|
|
57
63
|
const styles = stylesheet.create({
|
|
58
64
|
emoji: {
|
|
59
65
|
'.': ClassNames.emoji,
|