fix(ui): canvas infinite loop when setting bbox dims

When typing in a number into the w/h number inputs, if the number is less than the step, it appears the value of 0 is used. This is unexpected; it means Chakra isn't clamping the value correctly (or maybe our wrapper isn't clamping it).

Add checks to never bail if the width or height value from the number input component is 0.
This commit is contained in:
psychedelicious 2024-05-02 09:12:14 +10:00 committed by Kent Keirsey
parent 8ceb94497e
commit 1b617768cf
2 changed files with 12 additions and 0 deletions

View File

@ -16,6 +16,9 @@ export const ImageSizeCanvas = memo(() => {
const onChangeWidth = useCallback(
(width: number) => {
if (width === 0) {
return;
}
dispatch(setBoundingBoxDimensions({ width }, optimalDimension));
},
[dispatch, optimalDimension]
@ -23,6 +26,9 @@ export const ImageSizeCanvas = memo(() => {
const onChangeHeight = useCallback(
(height: number) => {
if (height === 0) {
return;
}
dispatch(setBoundingBoxDimensions({ height }, optimalDimension));
},
[dispatch, optimalDimension]

View File

@ -18,6 +18,9 @@ export const ImageSizeLinear = memo(() => {
const onChangeWidth = useCallback(
(width: number) => {
if (width === 0) {
return;
}
dispatch(widthChanged({ width }));
},
[dispatch]
@ -25,6 +28,9 @@ export const ImageSizeLinear = memo(() => {
const onChangeHeight = useCallback(
(height: number) => {
if (height === 0) {
return;
}
dispatch(heightChanged({ height }));
},
[dispatch]