From 0a606f6d2362bab53b2b07c91c128731f5203b4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mih=C3=A1ly=20H=C3=B3bor?= Date: Thu, 2 Apr 2026 16:08:59 +0200 Subject: [PATCH] Fix issue where cannot delete input field before input --- src/components/NotificationTemplate.jsx | 38 ++++++------------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/src/components/NotificationTemplate.jsx b/src/components/NotificationTemplate.jsx index 98c39de..734fd0b 100644 --- a/src/components/NotificationTemplate.jsx +++ b/src/components/NotificationTemplate.jsx @@ -589,44 +589,24 @@ const NotificationTemplate = ({ const val = e.target.value if (val.includes('-')) return - // Prevent setting to '0' if an 'On Due' already exists elsewhere - if (val === '0' || val === '') { - if (hasOnDueElsewhere) return - } - setDraftValues(prev => ({ ...prev, [idx]: val })) }} onKeyDown={e => { if (['-', 'e', '+', '.'].includes(e.key)) { e.preventDefault() - return - } - - // Physically block typing '0' if 'On Due' exists - if ( - e.key === '0' || - e.key === 'Backspace' || - e.key === 'Delete' - ) { - const currentVal = - draftValues[idx] !== undefined - ? draftValues[idx] - : uiRep.displayValue.toString() - - // If typing 0 into an empty input, or deleting the last character - const willBeZero = - (e.key === '0' && currentVal === '') || - ((e.key === 'Backspace' || e.key === 'Delete') && - currentVal.length <= 1) - - if (willBeZero && hasOnDueElsewhere) { - e.preventDefault() - } } }} onBlur={e => { let val = e.target.value - if (val === '' || Number(val) < 0) val = 0 + + const numericVal = Number(val) + val = + numericVal <= 0 + ? hasOnDueElsewhere + ? 1 + : 0 + : numericVal + handleChange(idx, 'displayValue', val) setDraftValues(prev => { const next = { ...prev }