Skip to content

Commit

Permalink
fix: do not allow decimals in duration input (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
chloe-renaud authored Nov 28, 2024
1 parent cfe9591 commit bbe39c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Duration/DateElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function DateElement(props: DateElementProps) {
value={durationValues.years}
allowNegative={false}
allowLeadingZeros={false}
decimalScale={0}
isAllowed={({ floatValue }) =>
floatValue === undefined || (floatValue >= 1 && floatValue <= 9999)
}
Expand All @@ -54,6 +55,7 @@ export function DateElement(props: DateElementProps) {
allowNegative={false}
dsfrProps={{ label: "Mois" }}
allowLeadingZeros
decimalScale={0}
isAllowed={({ floatValue }) =>
floatValue === undefined || (floatValue >= 0 && floatValue <= 11)
}
Expand Down
2 changes: 2 additions & 0 deletions src/Duration/TimeElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export function TimeElement(props: TimeElementProps) {
dsfrProps={{ label: "Heures" }}
inputMode="numeric"
allowLeadingZeros={false}
decimalScale={0}
isAllowed={({ floatValue }) =>
floatValue === undefined || (floatValue >= 0 && floatValue <= 99)
}
Expand All @@ -54,6 +55,7 @@ export function TimeElement(props: TimeElementProps) {
label: "Minutes",
}}
allowLeadingZeros
decimalScale={0}
isAllowed={({ floatValue }) =>
floatValue === undefined || (floatValue >= 0 && floatValue <= 59)
}
Expand Down

0 comments on commit bbe39c2

Please sign in to comment.