From 267188373cdd8159f9f82389e5adde6c1ee87cc2 Mon Sep 17 00:00:00 2001 From: rlacodud <74367207+rlacodud@users.noreply.github.com> Date: Sun, 14 Apr 2024 18:07:49 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EA=B3=B1=ED=95=98=EA=B8=B0=20=EA=B8=B0?= =?UTF-8?q?=ED=98=B8=20x=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Keyboard/index.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/Keyboard/index.tsx b/src/components/Keyboard/index.tsx index fc4fcda..1c97f69 100644 --- a/src/components/Keyboard/index.tsx +++ b/src/components/Keyboard/index.tsx @@ -16,7 +16,7 @@ const keyboardButtons = { { label: '7', gridArea: 'seven' }, { label: '8', gridArea: 'eight' }, { label: '9', gridArea: 'nine' }, - { label: 'x', value: '*', gridArea: 'multiply' }, + { label: 'x', value: 'x', gridArea: 'multiply' }, { label: '4', gridArea: 'four' }, { label: '5', gridArea: 'five' }, { label: '6', gridArea: 'six' }, @@ -63,9 +63,10 @@ function Keyboard() { const calc: Calc = { basic: () => { try { + const replaceResult = calcValue.basic.replace(/\x/g, '*'); return { inputs: [calcValue.basic], - results: [math.evaluate(calcValue.basic)] + results: [math.evaluate(replaceResult)] }; } catch (error) { return { @@ -170,8 +171,10 @@ function Keyboard() { const targetButton = buttonRefs.current.find(button => { if (value === ' ') return button?.value === ','; + if (value === '*') return button?.value === 'x'; return button?.value === value; }); + targetButton?.classList.add('active'); }; @@ -185,6 +188,7 @@ function Keyboard() { } const targetButton = buttonRefs.current.find(button => { if (value === ' ') return button?.value === ','; + if (value === '*') return button?.value === 'x'; return button?.value === value; }); targetButton?.classList.remove('active');