Skip to content

Commit 279e402

Browse files
committed
fix: remove mouse enter event on mobile
1 parent c67248f commit 279e402

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

apps/renderer/src/modules/entry-column/Items/social-media-item.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import { useMobile } from "@follow/components/hooks/useMobile.js"
12
import { ActionButton } from "@follow/components/ui/button/index.js"
23
import { Skeleton } from "@follow/components/ui/skeleton/index.jsx"
34
import { cn } from "@follow/utils/utils"
45
import { atom } from "jotai"
5-
import { useLayoutEffect, useRef, useState } from "react"
6+
import { useLayoutEffect, useMemo, useRef, useState } from "react"
67

78
import { RelativeTime } from "~/components/ui/datetime"
89
import { Media } from "~/components/ui/media"
@@ -34,6 +35,17 @@ export const SocialMediaItem: EntryListItemFC = ({ entryId, entryPreview, transl
3435

3536
const ref = useRef<HTMLDivElement>(null)
3637
const [showAction, setShowAction] = useState(false)
38+
39+
const isMobile = useMobile()
40+
const handleMouseEnter = useMemo(() => {
41+
if (isMobile) return
42+
return () => setShowAction(true)
43+
}, [isMobile])
44+
const handleMouseLeave = useMemo(() => {
45+
if (isMobile) return
46+
return () => setShowAction(false)
47+
}, [isMobile])
48+
3749
useLayoutEffect(() => {
3850
if (ref.current) {
3951
jotaiStore.set(socialMediaContentWidthAtom, ref.current.offsetWidth)
@@ -50,8 +62,8 @@ export const SocialMediaItem: EntryListItemFC = ({ entryId, entryPreview, transl
5062

5163
return (
5264
<div
53-
onMouseEnter={() => setShowAction(true)}
54-
onMouseLeave={() => setShowAction(false)}
65+
onMouseEnter={handleMouseEnter}
66+
onMouseLeave={handleMouseLeave}
5567
className={cn(
5668
"relative flex px-2 py-6 lg:px-8",
5769
"group",

0 commit comments

Comments
 (0)