fix: copy behaviour

This commit is contained in:
gosangam
2026-05-11 16:58:15 +05:30
parent 8cd1d2e724
commit cc94296b46
3 changed files with 42 additions and 29 deletions
+2 -26
View File
@@ -1,10 +1,9 @@
"use client";
import { useEffect, useRef, useState } from "react";
import { useEffect, useRef } from "react";
import { createPortal } from "react-dom";
import { useCopyFeedback, type Position } from "./shared";
import { buildShortHighlightUrl } from "@/lib/text-highlight";
import { Bookmark, FolderPlus, AtSign, Link2, Check } from "lucide-react";
import { Bookmark, FolderPlus, AtSign } from "lucide-react";
import {
Drawer,
DrawerClose,
@@ -34,18 +33,6 @@ export function MorePopover({
}) {
const ref = useRef<HTMLDivElement>(null);
const { copied, copy } = useCopyFeedback();
const [generatingLink, setGeneratingLink] = useState(false);
async function handleCopyLink() {
if (generatingLink) return;
setGeneratingLink(true);
try {
const url = await buildShortHighlightUrl(selectedText);
await copy(url);
} finally {
setGeneratingLink(false);
}
}
useEffect(() => {
if (!open || isMobile) return;
@@ -80,17 +67,6 @@ export function MorePopover({
icon: <FolderPlus className="size-5" />,
onClick: onSaveToCollection,
},
{
key: "copy-link",
label: copied
? "Link Copied!"
: generatingLink
? "Generating link…"
: "Copy Link",
description: "Copy a shareable link to this quote",
icon: copied ? <Check className="size-5" /> : <Link2 className="size-5" />,
onClick: handleCopyLink,
},
{
key: "mention",
label: "Mention",