블럭처리 #574

Merged
ysCha merged 1 commits from dev into dev-deploy 2026-01-12 11:13:03 +09:00

View File

@ -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