From 32432ec61245172d2ec46b03ea21e1abd65e1e4c Mon Sep 17 00:00:00 2001 From: Ajay Bura <32841439+ajbura@users.noreply.github.com> Date: Tue, 23 Jul 2024 19:17:01 +0530 Subject: [PATCH] fix null gets saved as page zoom --- src/app/organisms/settings/Settings.jsx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/app/organisms/settings/Settings.jsx b/src/app/organisms/settings/Settings.jsx index e43e90fb..6329a57f 100644 --- a/src/app/organisms/settings/Settings.jsx +++ b/src/app/organisms/settings/Settings.jsx @@ -71,11 +71,10 @@ function AppearanceSection() { const [showHiddenEvents, setShowHiddenEvents] = useSetting(settingsAtom, 'showHiddenEvents'); const spacings = ['0', '100', '200', '300', '400', '500']; - const [currentZoom, setCurrentZoom] = useState(pageZoom); + const [currentZoom, setCurrentZoom] = useState(`${pageZoom}`); const handleZoomChange = (evt) => { - const newZoom = parseInt(evt.target.value, 10); - setCurrentZoom(newZoom ?? 100); + setCurrentZoom(evt.target.value); }; const handleZoomEnter = (evt) => { @@ -85,9 +84,7 @@ function AppearanceSection() { } if (isKeyHotkey('enter', evt)) { const newZoom = parseInt(evt.target.value, 10); - if (typeof newZoom !== 'number' && Number.isNaN(newZoom)) { - return; - } + if (Number.isNaN(newZoom)) return; const safeZoom = Math.max(Math.min(newZoom, 150), 75); setPageZoom(safeZoom); setCurrentZoom(safeZoom); @@ -142,7 +139,7 @@ function AppearanceSection() { options={ <Input style={{ width: toRem(150) }} - variant={pageZoom !== currentZoom ? 'Primary' : 'Background'} + variant={pageZoom === parseInt(currentZoom, 10) ? 'Background' : 'Primary'} size="400" type="number" min="75" @@ -151,7 +148,7 @@ function AppearanceSection() { onChange={handleZoomChange} onKeyDown={handleZoomEnter} outlined - after={<Text variant="b2">%{pageZoom !== currentZoom ? ' (Enter)' : ''}</Text>} + after={<Text variant="b2">%</Text>} /> } content={