Skip to content

Commit 1634ad1

Browse files
andrew-polkclaude
andcommitted
Fix BL-16448 alignControlFrameWithActiveElement is not a function
https://issues.bloomlibrary.org/youtrack/issue/BL-16448 The exported adjustBackgroundImageSize() in CanvasElementBackgroundImageManager.ts declared its optional cropInfo? parameter *before* two required callback parameters (getActiveElement and alignControlFrameWithActiveElement). The setupBackgroundImageAttributes() caller, which runs when opening the edit tab for a page with a background image, omits cropInfo and passes only 6 args. Those two callbacks then landed in the wrong parameter slots, leaving the real alignControlFrameWithActiveElement parameter undefined. The later call to alignControlFrameWithActiveElement() threw "alignControlFrameWithActiveElement is not a function" (surfaced as an error toast). This type-level mistake ("a required parameter cannot follow an optional parameter") was not caught because the build uses Vite/esbuild, which strips TS types without type-checking. Fix: move cropInfo? to the end of adjustBackgroundImageSize()'s parameter list (after the required callbacks) and update the matching call in CanvasElementManager.adjustBackgroundImageSize to pass cropInfo last. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent a5e0af9 commit 1634ad1

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

src/BloomBrowserUI/bookEdit/js/canvasElementManager/CanvasElementBackgroundImageManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,9 @@ export function adjustBackgroundImageSize(
293293
bloomCanvas: HTMLElement,
294294
bgCanvasElement: HTMLElement,
295295
useSizeOfNewImage: boolean,
296-
cropInfo?: IImageCropInfo,
297296
getActiveElement: () => HTMLElement | undefined,
298297
alignControlFrameWithActiveElement: () => void,
298+
cropInfo?: IImageCropInfo,
299299
): Promise<void> {
300300
// adjustBackgroundImageSizeToFit may wait for the image to load and make modifications after,
301301
// and we want to make sure those modifications are included in any save that occurs in the meantime.

src/BloomBrowserUI/bookEdit/js/canvasElementManager/CanvasElementManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3122,9 +3122,9 @@ export class CanvasElementManager {
31223122
bloomCanvas,
31233123
bgCanvasElement,
31243124
useSizeOfNewImage,
3125-
cropInfo,
31263125
() => this.activeElement,
31273126
this.alignControlFrameWithActiveElement,
3127+
cropInfo,
31283128
);
31293129
}
31303130

0 commit comments

Comments
 (0)