Skip to content

Commit

Permalink
fix: don't throw undefined error if rapidly zooming browser in some e…
Browse files Browse the repository at this point in the history
…nvironments

Some users were reporting the following error when zooming their browser
(not Puck's internal zoom) quickly:

> TypeError: Cannot read properties of undefined (reading 'value') at
ViewportControls

Unable to reproduce, but user confirmed this helped.
  • Loading branch information
chrisvxd authored Apr 1, 2024
1 parent 5c05f94 commit 282a8b0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/core/components/ViewportControls/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export const ViewportControls = ({
<div className={getClassName("divider")} />
<IconButton
title="Zoom viewport out"
disabled={zoom <= zoomOptions[0].value}
disabled={zoom <= zoomOptions[0]?.value}
onClick={(e) => {
e.stopPropagation();
onZoom(
Expand All @@ -139,7 +139,7 @@ export const ViewportControls = ({
</IconButton>
<IconButton
title="Zoom viewport in"
disabled={zoom >= zoomOptions[zoomOptions.length - 1].value}
disabled={zoom >= zoomOptions[zoomOptions.length - 1]?.value}
onClick={(e) => {
e.stopPropagation();

Expand Down

0 comments on commit 282a8b0

Please sign in to comment.