This commit is contained in:
afkarxyz
2025-11-30 05:38:44 +07:00
parent 2653586eea
commit cc3f7640c6
12 changed files with 271 additions and 308 deletions
@@ -32,7 +32,7 @@ const InputWithContext = React.forwardRef<HTMLInputElement, InputWithContextProp
setHasSelection(start !== end);
};
// Check clipboard permission
// Check clipboard permission when user explicitly opens the context menu.
const checkClipboard = async () => {
try {
const text = await navigator.clipboard.readText();
@@ -42,10 +42,6 @@ const InputWithContext = React.forwardRef<HTMLInputElement, InputWithContextProp
}
};
React.useEffect(() => {
checkClipboard();
}, []);
const handleCut = async () => {
const input = inputRef.current;
if (!input) return;
@@ -156,7 +152,13 @@ const InputWithContext = React.forwardRef<HTMLInputElement, InputWithContextProp
};
return (
<ContextMenu onOpenChange={checkClipboard}>
<ContextMenu
onOpenChange={(open) => {
if (open) {
checkClipboard();
}
}}
>
<ContextMenuTrigger asChild>
<Input
ref={inputRef}