From 84c88ea6d3e8a6c2e6c729628471a74b92f990fc Mon Sep 17 00:00:00 2001 From: Andreas Weyer Date: Mon, 24 Nov 2025 18:48:20 +0000 Subject: [PATCH] Fix therapeutic range input --- src/App.js | 2 +- src/components/NumericInput.js | 15 +++-- src/components/Settings.js | 112 +++++++++++++++++---------------- src/constants/defaults.js | 2 +- 4 files changed, 70 insertions(+), 61 deletions(-) diff --git a/src/App.js b/src/App.js index 7279df8..5d97f72 100644 --- a/src/App.js +++ b/src/App.js @@ -139,7 +139,7 @@ const MedPlanAssistant = () => { therapeuticRange={therapeuticRange} uiSettings={uiSettings} onUpdatePkParams={(key, value) => updateNestedState('pkParams', key, value)} - onUpdateTherapeuticRange={(key, value) => updateNestedState('therapeuticRange', key, { [key]: value })} + onUpdateTherapeuticRange={(key, value) => updateNestedState('therapeuticRange', key, value)} onUpdateUiSetting={updateUiSetting} onReset={handleReset} t={t} diff --git a/src/components/NumericInput.js b/src/components/NumericInput.js index c3d3a4b..fcbbef8 100644 --- a/src/components/NumericInput.js +++ b/src/components/NumericInput.js @@ -10,11 +10,14 @@ const NumericInput = ({ unit, align = 'right', // 'left', 'center', 'right' allowEmpty = false, // Allow empty value (e.g., for "Auto" mode) + clearButton = false, // Show clear button (with allowEmpty=true) errorMessage = 'This field is required' // Error message for mandatory empty fields }) => { const [hasError, setHasError] = React.useState(false); const [showErrorTooltip, setShowErrorTooltip] = React.useState(false); const containerRef = React.useRef(null); + const showClearButton = clearButton && allowEmpty; + // Determine decimal places based on increment const getDecimalPlaces = () => { const inc = String(increment || '1'); @@ -158,14 +161,14 @@ const NumericInput = ({ return (
- {allowEmpty && ( + {showClearButton && (