diff --git a/app/src/gui/components/autoincrement/edit-form.tsx b/app/src/gui/components/autoincrement/edit-form.tsx index db83ef1c6..1ec8e3567 100644 --- a/app/src/gui/components/autoincrement/edit-form.tsx +++ b/app/src/gui/components/autoincrement/edit-form.tsx @@ -80,7 +80,6 @@ export const AutoIncrementEditForm = ({ ); return ranges; }, - initialData: [], enabled: true, }); @@ -112,9 +111,11 @@ export const AutoIncrementEditForm = ({ const updateRange = (index: number) => { return (range: LocalAutoIncrementRange) => { - const rangesCopy = [...ranges]; - rangesCopy[index] = range; - updateRanges(rangesCopy); + if (ranges) { + const rangesCopy = [...ranges]; + rangesCopy[index] = range; + updateRanges(rangesCopy); + } }; }; @@ -207,20 +208,25 @@ type IncremenenterRangeProps = { * @param props component props */ const IncrementerRange = (props: IncremenenterRangeProps) => { - const [start, setStart] = useState(props.range.start); - const [stop, setStop] = useState(props.range.stop); + const [start, setStart] = useState(props.range.start); + const [stop, setStop] = useState(props.range.stop); const handleStartChange = (event: any) => { + if (event.target.value === '') { + // set start but don't update the range + setStart(''); + return; + } const newStart = parseInt(event.target.value); if (newStart >= 0) { setStart(newStart); if (newStart >= props.range.stop) { // initialise a range of 100 if they enter a start > stop - setStop(newStart + 100); + setStop(newStart + 99); props.updateRange({ ...props.range, start: newStart, - stop: newStart + 100, + stop: newStart + 99, }); } else { props.updateRange({ @@ -232,6 +238,11 @@ const IncrementerRange = (props: IncremenenterRangeProps) => { }; const handleStopChange = (event: any) => { + if (event.target.value === '') { + // set stop but don't update the range + setStop(''); + return; + } const newStop = parseInt(event.target.value); if (newStop > props.range.start) { setStop(newStop); diff --git a/app/src/gui/components/record/form.tsx b/app/src/gui/components/record/form.tsx index ad79cc530..51744e610 100644 --- a/app/src/gui/components/record/form.tsx +++ b/app/src/gui/components/record/form.tsx @@ -45,7 +45,6 @@ import { upsertFAIMSData, } from '@faims3/data-model'; import {NavigateFunction} from 'react-router-dom'; -import {DEBUG_APP} from '../../../buildconfig'; import * as ROUTES from '../../../constants/routes'; import {store} from '../../../context/store'; import {getFieldPersistentData} from '../../../local-data/field-persistent';