Skip to content

Commit

Permalink
front: fixed bug or first number of the position field cannot be cleared
Browse files Browse the repository at this point in the history
  • Loading branch information
theocrsb committed Jul 2, 2024
1 parent c6498a4 commit 4a8884c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion front/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@
"offset": {
"label": "Position",
"description": "Offset of the point in meters to the beginning of the track section",
"error": "The offset of the split point to the beginning must be greater than 0 and smaller than {{max}}"
"error": "The offset of the split point to the beginning must be greater than 1 and smaller than {{max}}"
},
"actions": {
"save": "Save the split"
Expand Down
2 changes: 1 addition & 1 deletion front/public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@
"offset": {
"label": "Position",
"description": "Distance entre le point et le début du TIV (en mètres)",
"error": "La position doit être un nombre compris entre 0 et {{max}}"
"error": "La position doit être un nombre compris entre 1 et {{max}}"
},
"actions": {
"save": "Sauvegarder la division"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ const TrackSplitLeftPanel: FC<unknown> = () => {
id="offset"
type="number"
inputProps={{ required: true }}
value={state.offset / 1000}
min={0}
value={state.offset === 0 ? '' : state.offset / 1000}
min={1}
max={trackLength}
whiteBG
focus
Expand All @@ -100,8 +100,10 @@ const TrackSplitLeftPanel: FC<unknown> = () => {
: undefined
}
onChange={(e) => {
if (!Number.isNaN(e.target.valueAsNumber))
setState((prev) => ({ ...prev, offset: e.target.valueAsNumber * 1000 }));
setState((prev) => ({
...prev,
offset: e.target.valueAsNumber * 1000 || 0,
}));
}}
/>
</form>
Expand Down

0 comments on commit 4a8884c

Please sign in to comment.