From 2b5ca8af125db447b7e244775a94f8c81a790b40 Mon Sep 17 00:00:00 2001 From: Penar Musaraj Date: Tue, 13 Oct 2020 20:06:09 -0400 Subject: [PATCH] FIX: Wizard theme preview when logo is missing (#10914) Fixes empty theme previews in the wizard, a bug introduced by yours truly in a4356b99af0a7f4cd746b5d09960ab7635fe91a4 --- app/assets/javascripts/wizard/lib/preview.js | 25 ++++++++++---------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/app/assets/javascripts/wizard/lib/preview.js b/app/assets/javascripts/wizard/lib/preview.js index 73b4513d224..fd17028beef 100644 --- a/app/assets/javascripts/wizard/lib/preview.js +++ b/app/assets/javascripts/wizard/lib/preview.js @@ -161,21 +161,22 @@ export function createPreviewComponent(width, height, obj) { drawHeader(ctx, colors, width, headerHeight); const avatarSize = height * 0.1; - - // Logo const headerMargin = headerHeight * 0.2; - const logoHeight = headerHeight - headerMargin * 2; - const ratio = logoHeight / logo.height; - this.scaleImage( - logo, - headerMargin, - headerMargin, - logo.width * ratio, - logoHeight - ); + if (logo) { + const logoHeight = headerHeight - headerMargin * 2; - this.scaleImage(logo, width, headerMargin); + const ratio = logoHeight / logo.height; + this.scaleImage( + logo, + headerMargin, + headerMargin, + logo.width * ratio, + logoHeight + ); + + this.scaleImage(logo, width, headerMargin); + } // Top right menu this.scaleImage(