From aa837d8dbf3e6344f9ee59b2aca4c037d8ccdfe1 Mon Sep 17 00:00:00 2001 From: ysCha Date: Mon, 12 Jan 2026 11:12:29 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B8=94=EB=9F=AD=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/input/CalcInput.jsx | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/components/common/input/CalcInput.jsx b/src/components/common/input/CalcInput.jsx index 9cfddfd4..e8a97b93 100644 --- a/src/components/common/input/CalcInput.jsx +++ b/src/components/common/input/CalcInput.jsx @@ -63,6 +63,33 @@ export const CalculatorInput = forwardRef( const calculator = calculatorRef.current let newDisplayValue = '' + // 블록 지정(Selection) 확인 및 처리 + if (inputRef.current) { + const { selectionStart, selectionEnd } = inputRef.current + // 텍스트 전체 또는 일부가 블록 지정된 경우 + if (selectionStart !== null && selectionEnd !== null && selectionStart !== selectionEnd) { + // 연산 중이 아닐 때만 전체 초기화 후 입력 처리 (계산기 모드 유지를 위해) + if (!hasOperation) { + calculator.currentOperand = num.toString() + calculator.previousOperand = '' + calculator.operation = undefined + calculator.shouldResetDisplay = false + + newDisplayValue = calculator.currentOperand + setDisplayValue(newDisplayValue) + onChange(newDisplayValue) + + requestAnimationFrame(() => { + if (inputRef.current) { + inputRef.current.focus() + inputRef.current.setSelectionRange(newDisplayValue.length, newDisplayValue.length) + } + }) + return // 블록 처리 로직 완료 후 종료 + } + } + } + // maxLength 체크 if (maxLength > 0) { const currentLength = (calculator.currentOperand || '').length + (calculator.previousOperand || '').length + (calculator.operation || '').length