From dcdb18f8234be7be1e8649c8601448dde29a0f25 Mon Sep 17 00:00:00 2001 From: Mikadifo Date: Thu, 11 Sep 2025 21:44:57 -0400 Subject: [PATCH] fix user deleting negation when it's the only character left in the input (issue #882) --- src/numeric_format.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/numeric_format.tsx b/src/numeric_format.tsx index e96cffb1..ac42d107 100644 --- a/src/numeric_format.tsx +++ b/src/numeric_format.tsx @@ -408,6 +408,12 @@ export function useNumericFormat( const { key } = e; const { selectionStart, selectionEnd, value = '' } = el; + // if the input has only negation, allow the user to delete it + if (key === 'Backspace' && value === '-') { + onKeyDown(e); + return; + } + // if user tries to delete partial prefix then ignore it if ((key === 'Backspace' || key === 'Delete') && selectionEnd < prefix.length) { e.preventDefault();