Skip to content

Upgrade to node 22#594

Open
benjaminLeongSK wants to merge 9 commits into
mainfrom
BL/1804
Open

Upgrade to node 22#594
benjaminLeongSK wants to merge 9 commits into
mainfrom
BL/1804

Conversation

@benjaminLeongSK
Copy link
Copy Markdown
Contributor

Changes
Upgrading of node version

  • [delete] branch

Changelog entry

  • Fix audit issues
  • Bump dependencies
  • Replace deprecated test functions

Additional information

  • You may refer to this CCUBE-1804
  • For vulnerabilities in Dependabot alerts will have to wait till this branch is merged in for it to be updated and tackled

@benjaminLeongSK benjaminLeongSK requested a review from qroll May 5, 2026 01:50
qroll
qroll previously approved these changes May 5, 2026
Comment thread rollup.config.js
Comment thread scripts/patch-jsdom.js Outdated
Comment thread src/__tests__/components/fields/file-upload/file-upload.spec.tsx
Comment thread package-lock.json
Comment thread src/components/fields/image-upload/image-review/image-editor/image-editor.tsx Outdated
Comment on lines -194 to -200
fabricCanvas.current.clipPath = new Rect({
left: img.left,
top: img.top,
width: img.getScaledWidth(),
height: img.getScaledHeight(),
});

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer need a Fabric clipPath because export now crops to the background image bounds using getBoundingRect().

const eraserBrush = useRef<EraserBrush>();
const gestures = useRef({
pinchStartAmount: 0,
pan: new Point(0, 0),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep our pan position separated so we can use Fabric's public absolutePan API instead of mutating viewportTransform directly

Comment on lines +34 to +42
const syncCanvasDimensions = () => {
if (!wrapperRef.current || !fabricCanvas.current) return;

fabricCanvas.current.setDimensions({
width: wrapperRef.current.clientWidth,
height: wrapperRef.current.clientHeight,
});
};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to keep the Fabric canvas dimensions in sync with the wrapper element before fitting or exporting the image.

// recursively compress image until it fits limit
const toDataURLWithLimit = (limit = maxSizeInKb, quality = 1): string => {
if (fabricBackground.current) {
const backgroundBounds = fabricBackground.current.getBoundingRect();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using getBoundingRect bcos Fabric 7 position/scale calculations are more reliable through object bounds than raw top, left, or scaled width values.

Comment thread src/components/fields/image-upload/image-review/image-editor/image-editor.tsx Outdated
Comment on lines +362 to +370
const oldZoom = fabricCanvas.current.getZoom();
const [ox, oy] = origin;
fabricCanvas.current.zoomToPoint(new Point(ox, oy), zoom);
const nextPan = new Point(
((gestures.current.pan.x + ox) / oldZoom) * zoom - ox,
((gestures.current.pan.y + oy) / oldZoom) * zoom - oy
);

fabricCanvas.current.setZoom(zoom);
applyPan(nextPan, zoom);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preserve the pinch focal point by converting the existing pan from the old zoom level to the new zoom level. and use setZoom with our own clamped pan calculation instead of zoomToPoint, because zoomToPoint updates the viewport transform directly.

@benjaminLeongSK
Copy link
Copy Markdown
Contributor Author

the canvas changes avoid direct viewportTransform mutation and use Fabric's public APIs (setDimensions, centerObject, setZoom, absolutePan) instead. pan is tracked separately so zoom and drag can be clamped consistently

Comment thread src/components/fields/image-upload/image-review/image-editor/image-editor.tsx Outdated
@weili-govtech weili-govtech self-requested a review May 7, 2026 06:44
Comment thread src/components/fields/image-upload/image-review/image-editor/image-editor.tsx Outdated
Comment thread src/components/fields/image-upload/image-review/image-editor/image-editor.tsx Outdated
Comment thread package.json Outdated
qroll
qroll previously approved these changes May 13, 2026
const canvasRef = useRef<HTMLCanvasElement>(null);
const fabricCanvas = useRef<FabricCanvas>();
const fabricBackground = useRef<FabricImage>();
const fittedImageBounds = useRef<{ left: number; top: number; width: number; height: number }>();
Copy link
Copy Markdown
Contributor

@qroll qroll May 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qn: where is fittedImageBounds assigned a value?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my apologies it seems to be missing. it should have been assigned a value in fitImageToCanvas

Comment thread .storybook/main.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants