@@ -26,17 +26,22 @@ type RollingStockEditorParameterFormProps = {
26
26
) => void ;
27
27
} ;
28
28
29
+ type RollingStockEditorParameterFormColumnProps = RollingStockEditorParameterFormProps & {
30
+ lastNonZeroMass : MultiUnitsParameter ;
31
+ setLastNonZeroMass : ( lastNonZeroMass : React . SetStateAction < MultiUnitsParameter > ) => void ;
32
+ } ;
33
+
29
34
// TODO: make the conditional return clearer
30
35
const RollingStockEditorParameterFormColumn = ( {
31
36
rollingStockValues,
32
37
setRollingStockValues,
38
+ lastNonZeroMass,
39
+ setLastNonZeroMass,
33
40
propertiesList,
34
- } : RollingStockEditorParameterFormProps & {
41
+ } : RollingStockEditorParameterFormColumnProps & {
35
42
propertiesList : SchemaProperty [ ] ;
36
43
} ) => {
37
44
const { t } = useTranslation ( 'translation' , { keyPrefix : 'rollingStock' } ) ;
38
- // The mass is sets by default to its min for a new rolling stock, so it should always be defined on first render
39
- const [ lastNonZeroMass , setLastNonZeroMass ] = useState ( rollingStockValues . mass ! ) ;
40
45
41
46
/** Handle change in value or unit in a multiunit input */
42
47
const handleMultiUnitParamChange = < U extends MultiUnit > (
@@ -225,6 +230,8 @@ const RollingStockEditorParameterForm = ({
225
230
effortCurves : EffortCurveForms | null ;
226
231
} ) => {
227
232
const { t } = useTranslation ( 'translation' , { keyPrefix : 'rollingStock' } ) ;
233
+ // The mass is sets by default to its min for a new rolling stock, so it should always be defined on first render
234
+ const [ lastNonZeroMass , setLastNonZeroMass ] = useState ( rollingStockValues . mass ! ) ;
228
235
const refListOfProperties = Object . keys ( RollingStockEditorParameter ) ;
229
236
230
237
const {
@@ -240,13 +247,17 @@ const RollingStockEditorParameterForm = ({
240
247
rollingStockValues = { rollingStockValues }
241
248
setRollingStockValues = { setRollingStockValues }
242
249
propertiesList = { leftSideList }
250
+ lastNonZeroMass = { lastNonZeroMass }
251
+ setLastNonZeroMass = { setLastNonZeroMass }
243
252
/>
244
253
</ div >
245
254
< div className = "col-xl-4 rollingstock-editor-input-container mb-3" >
246
255
< RollingStockEditorParameterFormColumn
247
256
rollingStockValues = { rollingStockValues }
248
257
setRollingStockValues = { setRollingStockValues }
249
258
propertiesList = { middleSideList }
259
+ lastNonZeroMass = { lastNonZeroMass }
260
+ setLastNonZeroMass = { setLastNonZeroMass }
250
261
/>
251
262
</ div >
252
263
< div className = "d-flex flex-column justify-content-between col-xl-4 pb-3" >
@@ -258,6 +269,8 @@ const RollingStockEditorParameterForm = ({
258
269
rollingStockValues = { rollingStockValues }
259
270
setRollingStockValues = { setRollingStockValues }
260
271
propertiesList = { rightSideList }
272
+ lastNonZeroMass = { lastNonZeroMass }
273
+ setLastNonZeroMass = { setLastNonZeroMass }
261
274
/>
262
275
</ div >
263
276
</ div >
0 commit comments