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
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useEffect } from 'react';
|
|
3
3
|
|
|
4
|
+
import { detectEmojyPartiallyBelowFold } from '../DomUtils/detectEmojyPartiallyBelowFold';
|
|
4
5
|
import { focusElement } from '../DomUtils/focusElement';
|
|
5
6
|
import {
|
|
6
7
|
allUnifiedFromEmojiElement,
|
|
@@ -107,11 +108,25 @@ export function useEmojiPreviewEvents(
|
|
|
107
108
|
// Pulling focus out of an external element steals the caret from
|
|
108
109
|
// host-app inputs (issue #320). The guard runs again inside the
|
|
109
110
|
// deferred callback in case focus moved out after this event.
|
|
110
|
-
|
|
111
|
+
// Partially visible buttons are never focused: focusing would make
|
|
112
|
+
// the browser scroll them into view, yanking the scroll position
|
|
113
|
+
// while the user is browsing (see also PR #509).
|
|
114
|
+
if (
|
|
115
|
+
!isExternalElementFocused() &&
|
|
116
|
+
!isPartiallyBelowFold(button, bodyRef)
|
|
117
|
+
) {
|
|
111
118
|
focusElement(button, () => !isExternalElementFocused());
|
|
112
119
|
}
|
|
113
120
|
}
|
|
114
121
|
|
|
122
|
+
function isPartiallyBelowFold(
|
|
123
|
+
button: HTMLButtonElement,
|
|
124
|
+
body: HTMLElement | null,
|
|
125
|
+
): boolean {
|
|
126
|
+
const belowFoldByPx = detectEmojyPartiallyBelowFold(button, body);
|
|
127
|
+
return belowFoldByPx < button.getBoundingClientRect().height;
|
|
128
|
+
}
|
|
129
|
+
|
|
115
130
|
function isExternalElementFocused(): boolean {
|
|
116
131
|
const active = document.activeElement as HTMLElement | null;
|
|
117
132
|
|
|
@@ -129,5 +144,5 @@ export function useEmojiPreviewEvents(
|
|
|
129
144
|
bodyRef?.removeEventListener('blur', onLeave, true);
|
|
130
145
|
bodyRef?.removeEventListener('keydown', onEscape);
|
|
131
146
|
};
|
|
132
|
-
}, [BodyRef, allow, setPreviewEmoji, isMouseDisallowed, allowMouseMove]);
|
|
147
|
+
}, [BodyRef, PickerMainRef, allow, setPreviewEmoji, isMouseDisallowed, allowMouseMove]);
|
|
133
148
|
}
|