fix: ui fixes

This commit is contained in:
gosangam
2026-06-14 15:56:58 +05:30
parent 0280a81777
commit 752ad20fed
2 changed files with 68 additions and 6 deletions
+7 -6
View File
@@ -12,10 +12,7 @@ import {
} from "lucide-react";
import { toast } from "sonner";
import { formatCopyText, getSourceReference } from "@/lib/source-reference";
import {
buildHighlightUrl,
buildShortHighlightUrl,
} from "@/lib/text-highlight";
import { buildHighlightUrl } from "@/lib/text-highlight";
import { bookmarks, SocialError } from "@/lib/social";
import {
KautilyaIcon,
@@ -393,8 +390,12 @@ export function TextSelectionToolbar() {
}
async function onCopyLink() {
const url = await buildShortHighlightUrl(selectedText);
await copy(url);
// Hand copy() the long ?hl= URL synchronously — it shortens it to the
// /share/<code> form inside the ClipboardItem promise, which keeps the
// click's transient activation alive so the short link copies in one go.
// (Pre-awaiting buildShortHighlightUrl here would burn the gesture and
// require a second click, the way "copy caption" via onCopyText doesn't.)
await copy(buildHighlightUrl(selectedText));
toast.success("Link copied", { duration: 1500 });
finishAction();
}