Emoji Picker: Fix losing focus in Safari (#1157)
This commit is contained in:
parent
74bc1b4154
commit
16f2a3a18e
@ -315,6 +315,7 @@ const Composer: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
const newHtml = renderText(text, ['escape_html', 'emoji_html', 'br_html'])
|
const newHtml = renderText(text, ['escape_html', 'emoji_html', 'br_html'])
|
||||||
.join('')
|
.join('')
|
||||||
.replace(/\u200b+/g, '\u200b');
|
.replace(/\u200b+/g, '\u200b');
|
||||||
|
|
||||||
if (selection.rangeCount) {
|
if (selection.rangeCount) {
|
||||||
const selectionRange = selection.getRangeAt(0);
|
const selectionRange = selection.getRangeAt(0);
|
||||||
if (isSelectionInsideInput(selectionRange)) {
|
if (isSelectionInsideInput(selectionRange)) {
|
||||||
@ -327,17 +328,15 @@ const Composer: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setHtml(`${htmlRef.current!}${newHtml}`);
|
setHtml(`${htmlRef.current!}${newHtml}`);
|
||||||
|
|
||||||
if (!IS_MOBILE_SCREEN) {
|
if (!IS_MOBILE_SCREEN) {
|
||||||
// If selection is outside of input, set cursor at the end of input
|
// If selection is outside of input, set cursor at the end of input
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
focusEditableElement(messageInput);
|
focusEditableElement(messageInput);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
} else {
|
|
||||||
setHtml(`${htmlRef.current!}${newHtml}`);
|
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
@ -11,14 +11,17 @@ type OwnProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const EmojiButton: FC<OwnProps> = ({ emoji, focus, onClick }) => {
|
const EmojiButton: FC<OwnProps> = ({ emoji, focus, onClick }) => {
|
||||||
const handleClick = useCallback(() => {
|
const handleClick = useCallback((e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
|
||||||
|
// Preventing safari from losing focus on Composer MessageInput
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
onClick(emoji.native, emoji.id);
|
onClick(emoji.native, emoji.id);
|
||||||
}, [emoji, onClick]);
|
}, [emoji, onClick]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`EmojiButton ${focus ? 'focus' : ''}`}
|
className={`EmojiButton ${focus ? 'focus' : ''}`}
|
||||||
onClick={handleClick}
|
onMouseDown={handleClick}
|
||||||
title={`:${emoji.names[0]}:`}
|
title={`:${emoji.names[0]}:`}
|
||||||
>
|
>
|
||||||
{IS_EMOJI_SUPPORTED
|
{IS_EMOJI_SUPPORTED
|
||||||
|
|||||||
@ -79,7 +79,7 @@ const Menu: FC<OwnProps> = ({
|
|||||||
}
|
}
|
||||||
}, [isOpen]);
|
}, [isOpen]);
|
||||||
|
|
||||||
const handleKeyDown = useKeyboardListNavigation(menuRef, isOpen, autoClose ? onClose : undefined);
|
const handleKeyDown = useKeyboardListNavigation(menuRef, isOpen, autoClose ? onClose : undefined, undefined, true);
|
||||||
|
|
||||||
useVirtualBackdrop(
|
useVirtualBackdrop(
|
||||||
isOpen,
|
isOpen,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user