mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-02-15 10:00:06 +00:00
fix null gets saved as page zoom
This commit is contained in:
parent
700f698167
commit
32432ec612
|
@ -71,11 +71,10 @@ function AppearanceSection() {
|
||||||
const [showHiddenEvents, setShowHiddenEvents] = useSetting(settingsAtom, 'showHiddenEvents');
|
const [showHiddenEvents, setShowHiddenEvents] = useSetting(settingsAtom, 'showHiddenEvents');
|
||||||
const spacings = ['0', '100', '200', '300', '400', '500'];
|
const spacings = ['0', '100', '200', '300', '400', '500'];
|
||||||
|
|
||||||
const [currentZoom, setCurrentZoom] = useState(pageZoom);
|
const [currentZoom, setCurrentZoom] = useState(`${pageZoom}`);
|
||||||
|
|
||||||
const handleZoomChange = (evt) => {
|
const handleZoomChange = (evt) => {
|
||||||
const newZoom = parseInt(evt.target.value, 10);
|
setCurrentZoom(evt.target.value);
|
||||||
setCurrentZoom(newZoom ?? 100);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleZoomEnter = (evt) => {
|
const handleZoomEnter = (evt) => {
|
||||||
|
@ -85,9 +84,7 @@ function AppearanceSection() {
|
||||||
}
|
}
|
||||||
if (isKeyHotkey('enter', evt)) {
|
if (isKeyHotkey('enter', evt)) {
|
||||||
const newZoom = parseInt(evt.target.value, 10);
|
const newZoom = parseInt(evt.target.value, 10);
|
||||||
if (typeof newZoom !== 'number' && Number.isNaN(newZoom)) {
|
if (Number.isNaN(newZoom)) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
const safeZoom = Math.max(Math.min(newZoom, 150), 75);
|
const safeZoom = Math.max(Math.min(newZoom, 150), 75);
|
||||||
setPageZoom(safeZoom);
|
setPageZoom(safeZoom);
|
||||||
setCurrentZoom(safeZoom);
|
setCurrentZoom(safeZoom);
|
||||||
|
@ -142,7 +139,7 @@ function AppearanceSection() {
|
||||||
options={
|
options={
|
||||||
<Input
|
<Input
|
||||||
style={{ width: toRem(150) }}
|
style={{ width: toRem(150) }}
|
||||||
variant={pageZoom !== currentZoom ? 'Primary' : 'Background'}
|
variant={pageZoom === parseInt(currentZoom, 10) ? 'Background' : 'Primary'}
|
||||||
size="400"
|
size="400"
|
||||||
type="number"
|
type="number"
|
||||||
min="75"
|
min="75"
|
||||||
|
@ -151,7 +148,7 @@ function AppearanceSection() {
|
||||||
onChange={handleZoomChange}
|
onChange={handleZoomChange}
|
||||||
onKeyDown={handleZoomEnter}
|
onKeyDown={handleZoomEnter}
|
||||||
outlined
|
outlined
|
||||||
after={<Text variant="b2">%{pageZoom !== currentZoom ? ' (Enter)' : ''}</Text>}
|
after={<Text variant="b2">%</Text>}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
content={
|
content={
|
||||||
|
|
Loading…
Reference in a new issue