emoji-picker-react 4.21.0 → 4.21.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/dist/emoji-picker-react.cjs.development.js +19 -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 +19 -2
- package/dist/emoji-picker-react.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/hooks/useEmojiPreviewEvents.ts +17 -2
|
@@ -29974,6 +29974,16 @@ var styles$a = /*#__PURE__*/stylesheet.create({
|
|
|
29974
29974
|
}
|
|
29975
29975
|
});
|
|
29976
29976
|
|
|
29977
|
+
function detectEmojyPartiallyBelowFold(button, bodyRef) {
|
|
29978
|
+
if (!button || !bodyRef) {
|
|
29979
|
+
return 0;
|
|
29980
|
+
}
|
|
29981
|
+
var buttonRect = button.getBoundingClientRect();
|
|
29982
|
+
var bodyRect = bodyRef.getBoundingClientRect();
|
|
29983
|
+
// If the element is obscured by at least half of its size
|
|
29984
|
+
return bodyRect.height - (buttonRect.y - bodyRect.y);
|
|
29985
|
+
}
|
|
29986
|
+
|
|
29977
29987
|
function useEmojiPreviewEvents(allow, setPreviewEmoji) {
|
|
29978
29988
|
var BodyRef = useBodyRef();
|
|
29979
29989
|
var PickerMainRef = usePickerMainRef();
|
|
@@ -30046,12 +30056,19 @@ function useEmojiPreviewEvents(allow, setPreviewEmoji) {
|
|
|
30046
30056
|
// Pulling focus out of an external element steals the caret from
|
|
30047
30057
|
// host-app inputs (issue #320). The guard runs again inside the
|
|
30048
30058
|
// deferred callback in case focus moved out after this event.
|
|
30049
|
-
|
|
30059
|
+
// Partially visible buttons are never focused: focusing would make
|
|
30060
|
+
// the browser scroll them into view, yanking the scroll position
|
|
30061
|
+
// while the user is browsing (see also PR #509).
|
|
30062
|
+
if (!isExternalElementFocused() && !isPartiallyBelowFold(button, bodyRef)) {
|
|
30050
30063
|
focusElement(button, function () {
|
|
30051
30064
|
return !isExternalElementFocused();
|
|
30052
30065
|
});
|
|
30053
30066
|
}
|
|
30054
30067
|
}
|
|
30068
|
+
function isPartiallyBelowFold(button, body) {
|
|
30069
|
+
var belowFoldByPx = detectEmojyPartiallyBelowFold(button, body);
|
|
30070
|
+
return belowFoldByPx < button.getBoundingClientRect().height;
|
|
30071
|
+
}
|
|
30055
30072
|
function isExternalElementFocused() {
|
|
30056
30073
|
var _PickerMainRef$curren;
|
|
30057
30074
|
var active = document.activeElement;
|
|
@@ -30067,7 +30084,7 @@ function useEmojiPreviewEvents(allow, setPreviewEmoji) {
|
|
|
30067
30084
|
bodyRef == null ? void 0 : bodyRef.removeEventListener('blur', onLeave, true);
|
|
30068
30085
|
bodyRef == null ? void 0 : bodyRef.removeEventListener('keydown', onEscape);
|
|
30069
30086
|
};
|
|
30070
|
-
}, [BodyRef, allow, setPreviewEmoji, isMouseDisallowed, allowMouseMove]);
|
|
30087
|
+
}, [BodyRef, PickerMainRef, allow, setPreviewEmoji, isMouseDisallowed, allowMouseMove]);
|
|
30071
30088
|
}
|
|
30072
30089
|
|
|
30073
30090
|
var _stylesheet$create;
|