Default the window zoom factor instead of passing NaN - #137
Conversation
window/open treats zoomFactor as optional, but parseFloat(undefined) is NaN and setZoomFactor(NaN) renders the page at an extreme zoom rather than being ignored. Native\Desktop\Windows\Window declares $zoomFactor = 1.0 and always serialises it, so the Laravel client never reaches this path — it only shows up for a caller that omits the key.
|
@simonhamp kindly review |
gwleuverink
left a comment
There was a problem hiding this comment.
Nice find. Confirmed the mechanism: Electron's check is factor < epsilon, and NaN fails that, so it slips straight past the throw and leaves the zoom broken.
The same line sits at /set-zoom-factor (window.ts:95). Could you grab that one while you're in here? A small shared helper would keep the two from drifting.
Both call sites now go through parseZoomFactor(), so a non-numeric or non-positive value falls back to 1 instead of reaching Electron as NaN.
|
Done in const DEFAULT_ZOOM_FACTOR = 1;
function parseZoomFactor(zoomFactor) {
const zoom = parseFloat(zoomFactor);
return Number.isFinite(zoom) && zoom > 0 ? zoom : DEFAULT_ZOOM_FACTOR;
}
I have not rebuilt |
gwleuverink
left a comment
There was a problem hiding this comment.
Perfect, thank you!
window/opendestructureszoomFactorfrom an optional payload and later does:When the key is absent that is
parseFloat(undefined)→NaN, andsetZoomFactor(NaN)does not no-op. The page renders at an extreme zoom. I hit this with a window showing about four enormous letters and no other symptom.Native\Desktop\Windows\Windowdeclaresprotected float $zoomFactor = 1.0and always serialises it, so the Laravel client never reaches this path. It only surfaces for a caller that omits the key, which the endpoint otherwise permits.The fix falls back to
1for anything non-finite or non-positive.