Skip to content

Commit

Permalink
fix: clear selection when pointer down, fixed #1448
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <[email protected]>
  • Loading branch information
Innei committed Nov 8, 2024
1 parent a607ad1 commit 33d3906
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apps/renderer/src/modules/entry-content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ScrollArea } from "@follow/components/ui/scroll-area/index.js"
import { useTitle } from "@follow/hooks"
import type { FeedModel, InboxModel } from "@follow/models/types"
import { IN_ELECTRON } from "@follow/shared/constants"
import { stopPropagation } from "@follow/utils/dom"
import { clearSelection, stopPropagation } from "@follow/utils/dom"
import { EventBus } from "@follow/utils/event-bus"
import { cn } from "@follow/utils/utils"
import type { FallbackRender } from "@sentry/react"
Expand Down Expand Up @@ -210,6 +210,7 @@ export const EntryContentRender: Component<{
ref={scrollerRef}
>
<div
onPointerDown={clearSelection}
style={stableRenderStyle}
className="duration-200 ease-in-out animate-in fade-in slide-in-from-bottom-24 f-motion-reduce:fade-in-0 f-motion-reduce:slide-in-from-bottom-0"
key={entry.entries.id}
Expand Down
2 changes: 2 additions & 0 deletions packages/utils/src/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ export const getElementTop = (element: HTMLElement) => {
}
return actualTop
}

export const clearSelection = () => window.getSelection()?.removeAllRanges()

0 comments on commit 33d3906

Please sign in to comment.