From af96478c7dba5d985f8a0f2e7f18c6974fc0b4c3 Mon Sep 17 00:00:00 2001 From: Felix Mosheev <9304194+felixmosh@users.noreply.github.com> Date: Wed, 26 Jul 2023 12:36:04 +0300 Subject: [PATCH] fix: limit jobsPerPage to max length of 2 chars + use Math.min --- packages/ui/src/components/SettingsModal/SettingsModal.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/ui/src/components/SettingsModal/SettingsModal.tsx b/packages/ui/src/components/SettingsModal/SettingsModal.tsx index e39cb945..3eb789bf 100644 --- a/packages/ui/src/components/SettingsModal/SettingsModal.tsx +++ b/packages/ui/src/components/SettingsModal/SettingsModal.tsx @@ -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}`, })); @@ -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) }); }} />