From c5b750bd089b15709d99e21f046fc39cf86c1b42 Mon Sep 17 00:00:00 2001 From: Timothy Cardoza Date: Wed, 18 Mar 2026 17:27:45 -0500 Subject: [PATCH] Calculator UI Fix --- src/components/CalculatorPopover.tsx | 49 ++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/src/components/CalculatorPopover.tsx b/src/components/CalculatorPopover.tsx index 6ad3d2f..cf47d7f 100644 --- a/src/components/CalculatorPopover.tsx +++ b/src/components/CalculatorPopover.tsx @@ -145,12 +145,31 @@ const CalculatorPopover: Component = () => { } }; + const handlePaste = (e: ClipboardEvent) => { + if (!isOpen()) return; + + // Don't intercept if an input is focused + const activeElement = document.activeElement; + const isInputFocused = activeElement instanceof HTMLInputElement || + activeElement instanceof HTMLTextAreaElement || + activeElement?.hasAttribute('contenteditable'); + + if (isInputFocused) return; + + const pastedText = e.clipboardData?.getData('text/plain'); + if (pastedText && !isNaN(parseFloat(pastedText))) { + addValue(parseFloat(pastedText), 'Pasted Value'); + } + }; + onMount(() => { window.addEventListener('keydown', handleKeyDown); + window.addEventListener('paste', handlePaste); }); onCleanup(() => { window.removeEventListener('keydown', handleKeyDown); + window.removeEventListener('paste', handlePaste); }); return ( @@ -182,19 +201,19 @@ const CalculatorPopover: Component = () => { {/* Display */} -
-
Calculation History
+
+
Calculation History
{(entry) => ( +
- {entry.label} + {entry.label}
{entry.type === 'result' && =} {formatNumber(entry.value || 0)} @@ -202,11 +221,11 @@ const CalculatorPopover: Component = () => {
}>
-
- +
+ {entry.label} -
+
)} @@ -259,17 +278,19 @@ const CalculatorPopover: Component = () => {
- + +