Skip to content

Commit

Permalink
fix: limit jobsPerPage to max length of 2 chars + use Math.min
Browse files Browse the repository at this point in the history
  • Loading branch information
felixmosh committed Jul 26, 2023
1 parent c3435dd commit af96478
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/ui/src/components/SettingsModal/SettingsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const pollingIntervals = [-1, 3, 5, 10, 20, 60, 60 * 5, 60 * 15].map((interval)
interval < 0
? 'Off'
: Math.floor(interval / 60) === 0
? `${interval} seconds`
: `${interval / 60} minutes`,
? `${interval} seconds`
: `${interval / 60} minutes`,
value: `${interval}`,
}));

Expand Down Expand Up @@ -49,9 +49,10 @@ export const SettingsModal = ({ open, onClose }: SettingsModalProps) => {
type="number"
min="1"
max="50"
maxLength={2}
onChange={(event) => {
const jobsPerPage = +event.target.value;
setSettings({ jobsPerPage: jobsPerPage > 50 ? 50 : jobsPerPage });
setSettings({ jobsPerPage: Math.min(jobsPerPage, 50) });
}}
/>
<SwitchField
Expand Down

0 comments on commit af96478

Please sign in to comment.