EmojiButtonWrapper: improve touch behavior

This commit is contained in:
Alex Gleason 2022-04-13 17:37:38 -05:00
parent eaf42370b9
commit 9596ed072b
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 9 additions and 1 deletions

View File

@ -44,13 +44,19 @@ const EmojiButtonWrapper: React.FC<IEmojiButtonWrapper> = ({ statusId, children
if (!status) return null; if (!status) return null;
const handleMouseEnter = () => { const handleMouseEnter = () => {
if (!isUserTouching()) {
setVisible(true); setVisible(true);
}
}; };
const handleMouseLeave = () => { const handleMouseLeave = () => {
setVisible(false); setVisible(false);
}; };
const handleUnfocus = () => {
setVisible(false);
};
const handleReact = (emoji: string): void => { const handleReact = (emoji: string): void => {
if (ownAccount) { if (ownAccount) {
dispatch(simpleEmojiReact(status, emoji)); dispatch(simpleEmojiReact(status, emoji));
@ -77,6 +83,7 @@ const EmojiButtonWrapper: React.FC<IEmojiButtonWrapper> = ({ statusId, children
handleReact(meEmojiReact); handleReact(meEmojiReact);
} }
e.preventDefault();
e.stopPropagation(); e.stopPropagation();
}; };
@ -106,6 +113,7 @@ const EmojiButtonWrapper: React.FC<IEmojiButtonWrapper> = ({ statusId, children
<div onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave}> <div onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave}>
{React.cloneElement(children, { {React.cloneElement(children, {
onClick: handleClick, onClick: handleClick,
onBlur: handleUnfocus,
ref, ref,
})} })}