Skip to content

Commit 577579d

Browse files
committed
Fix screenshots not showing in canvas step
1 parent 632e871 commit 577579d

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

build/2.7.4/onboarding.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'react-jsx-runtime', 'wp-api-fetch', 'wp-core-data', 'wp-data', 'wp-deprecated', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-media-utils', 'wp-preferences', 'wp-url'), 'version' => 'ea31651aae79aab1f7a2');
1+
<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'react-jsx-runtime', 'wp-api-fetch', 'wp-core-data', 'wp-data', 'wp-deprecated', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-media-utils', 'wp-preferences', 'wp-url'), 'version' => '32e03e6aa7e459eb7f8d');

build/2.7.4/onboarding.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/components/SiteGenPreviewCard/SiteGenPreviewCard.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,4 @@ const SiteGenPreviewCard = ( {
120120
);
121121
};
122122

123-
export default SiteGenPreviewCard;
123+
export default SiteGenPreviewCard;

src/app/steps/Canvas/Sidebar.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import { dispatch, useSelect } from '@wordpress/data';
2-
import { useState } from '@wordpress/element';
3-
import { __ } from '@wordpress/i18n';
42
import { Title } from '@newfold/ui-component-library';
53
import { XMarkIcon } from '@heroicons/react/24/outline';
64
import { SiteGenPreviewCard } from '@/components';
@@ -37,6 +35,17 @@ const Preview = ( { preview, tabIndex } ) => {
3735
};
3836
} );
3937

38+
const getScreenshot = () => {
39+
if ( preview.screenshot ) {
40+
// Set 500ms delay to avoid abrupt flickering.
41+
setTimeout( () => {
42+
setIsLoading( false );
43+
}, 500 );
44+
return preview.screenshot;
45+
}
46+
return null;
47+
};
48+
4049
const iframeOnLoad = () => {
4150
setTimeout( () => {
4251
// Set 500ms delay to allow the iframe to fully render.
@@ -50,7 +59,7 @@ const Preview = ( { preview, tabIndex } ) => {
5059

5160
return (
5261
<SiteGenPreviewCard
53-
screenshot={ preview.screenshot }
62+
screenshot={ getScreenshot() }
5463
frameName={ preview.slug }
5564
frameSrc={ preview.iframeSrc }
5665
onFrameLoad={ iframeOnLoad }
@@ -90,11 +99,11 @@ const Sidebar = () => {
9099

91100
return (
92101
<div
93-
className={`nfd-onboarding-canvas-sidebar nfd-h-full nfd-bg-white nfd-border-l nfd-overflow-y-auto nfd-transition-all nfd-duration-300 nfd-ease-in-out ${
94-
canvasSidebarIsOpen
95-
? 'nfd-min-w-[325px] nfd-max-w-[325px] nfd-opacity-100'
102+
className={ `nfd-onboarding-canvas-sidebar nfd-h-full nfd-bg-white nfd-border-l nfd-overflow-y-auto nfd-transition-all nfd-duration-300 nfd-ease-in-out ${
103+
canvasSidebarIsOpen
104+
? 'nfd-min-w-[325px] nfd-max-w-[325px] nfd-opacity-100'
96105
: 'nfd-min-w-0 nfd-max-w-0 nfd-opacity-0 nfd-overflow-hidden'
97-
}`}
106+
}` }
98107
role="region"
99108
aria-label={ __( 'Layouts sidebar', 'wp-module-onboarding' ) }
100109
aria-hidden={ ! canvasSidebarIsOpen }

0 commit comments

Comments
 (0)