Added the following lines of code and that resolved the issue. Cheers to @lavrton and @vanquished-wombat.
onTransformEnd={(event) => {
const tr = transformerRef.current;
const anchorName = tr.getActiveAnchor();
const fontSizeAnchors = [
"top-right",
"top-left",
"bottom-left",
"bottom-right"
];
if (!tr) return;
tr.nodes().forEach((group) => {
const children = group.getChildren();
children.forEach((node) => {
const textNode = node;
if (node.className === "Text") {
if (anchorName && fontSizeAnchors.includes(anchorName)) {
const absScale = textNode.getAbsoluteScale();
textNode.setAttrs({
fontSize: textNode.fontSize() * absScale.x,
width: textNode.width() * absScale.x,
x: textNode.x() * absScale.x,
y: textNode.y() * absScale.y,
scaleX: 1,
scaleY: 1
});
}
}
});
group.scaleX(1);
group.scaleY(1);
group.getLayer().batchDraw();
});
}}
onTransform={(event) => {
const tr = transformerRef.current;
const anchorName = tr?.getActiveAnchor();
const widthAnchors = ["middle-right", "middle-left"];
if (!tr) return;
tr.nodes().forEach((group) => {
const children = group.getChildren();
children.forEach((node) => {
if (node.className === "Text") {
const textNode = node;
const absScale = textNode.getAbsoluteScale();
if (widthAnchors.includes(anchorName)) {
textNode.setAttrs({
width: textNode.width() * absScale.x,
x: textNode.x() * absScale.x,
y: textNode.y() * absScale.y,
scaleX: 1,
scaleY: 1
});
}
}
});
if (widthAnchors.includes(anchorName)) {
group.scaleX(1);
group.scaleY(1);
}
});
}}