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