diff --git a/src/OnboardingSPA/components/LivePreview/SiteGenCard/index.js b/src/OnboardingSPA/components/LivePreview/SiteGenCard/index.js index 036d81d70..d24f36db2 100644 --- a/src/OnboardingSPA/components/LivePreview/SiteGenCard/index.js +++ b/src/OnboardingSPA/components/LivePreview/SiteGenCard/index.js @@ -90,13 +90,15 @@ const LivePreviewSiteGenCard = ( { { title } -
+
handleRegenerate() } + onKeyDown={ () => handleRegenerate() } + >
handleRegenerate() } - onKeyDown={ () => handleRegenerate() } >
{ const [ activeHomepage, setActiveHomepage ] = useState(); const [ globalStyles, setGlobalStyles ] = useState( [] ); const [ activeTab, setActiveTab ] = useState(); - const { currentData } = useSelect( ( select ) => { - return { - currentData: - select( nfdOnboardingStore ).getCurrentOnboardingData(), - }; - } ); + const { currentData, isSidebarOpened, sideBarView } = useSelect( + ( select ) => { + return { + currentData: + select( nfdOnboardingStore ).getCurrentOnboardingData(), + isSidebarOpened: select( nfdOnboardingStore ).isSidebarOpened(), + sideBarView: select( nfdOnboardingStore ).getSidebarView(), + }; + } + ); const { setIsSidebarOpened, setCurrentOnboardingData } = useDispatch( nfdOnboardingStore ); @@ -84,12 +88,11 @@ const SitegenEditorPatternsSidebar = () => { }; } } ); - currentData.sitegen.homepages.data = homepagesResponse; - setCurrentOnboardingData( currentData ); - homepagesResponse.forEach( ( homepage ) => { homepagesObject[ homepage.slug ] = homepage; } ); + currentData.sitegen.homepages.data = homepagesObject; + setCurrentOnboardingData( currentData ); } else { homepagesObject = currentData.sitegen.homepages.data; } @@ -100,19 +103,23 @@ const SitegenEditorPatternsSidebar = () => { }; useEffect( () => { - loadData(); - }, [] ); + if ( + SIDEBAR_SITEGEN_EDITOR_PATTERNS === sideBarView && + isSidebarOpened + ) { + loadData(); + } + }, [ sideBarView, isSidebarOpened ] ); useEffect( () => { setActiveTab( { - name: 'All Versions', + name: __( 'All Versions', 'wp-module-onboarding' ), title: (

{ __( 'All Versions', 'wp-module-onboarding' ) }

), content: - activeTab && homepages && activeHomepage && Object.keys( homepages ).map( ( homepage ) => { @@ -123,23 +130,28 @@ const SitegenEditorPatternsSidebar = () => { return (
handlePreview( data.slug ) } - role="button" - tabIndex={ 0 } - onKeyDown={ () => handlePreview( data.slug ) } key={ data.slug } > - +
handlePreview( data.slug ) } + role="button" + tabIndex={ 0 } + onKeyDown={ () => handlePreview( data.slug ) } + > + +
+
{ } tabs={ [ { - name: 'All Versions', + name: __( + 'All Versions', + 'wp-module-onboarding' + ), title: (

diff --git a/src/OnboardingSPA/steps/SiteGen/Preview/index.js b/src/OnboardingSPA/steps/SiteGen/Preview/index.js index ec2b09391..2db283565 100644 --- a/src/OnboardingSPA/steps/SiteGen/Preview/index.js +++ b/src/OnboardingSPA/steps/SiteGen/Preview/index.js @@ -58,11 +58,11 @@ const SiteGenPreview = () => { }; } } ); - currentData.sitegen.homepages.data = homepagesResponse; - setCurrentOnboardingData( currentData ); homepagesResponse.forEach( ( homepage ) => { homepagesObject[ homepage.slug ] = homepage; } ); + currentData.sitegen.homepages.data = homepagesObject; + setCurrentOnboardingData( currentData ); } else { homepagesObject = currentData.sitegen.homepages.data; } diff --git a/src/OnboardingSPA/steps/SiteGen/Preview/stylesheet.scss b/src/OnboardingSPA/steps/SiteGen/Preview/stylesheet.scss index 825c9aa2f..27a3ea8c7 100644 --- a/src/OnboardingSPA/steps/SiteGen/Preview/stylesheet.scss +++ b/src/OnboardingSPA/steps/SiteGen/Preview/stylesheet.scss @@ -13,7 +13,7 @@ color: var(--nfd-onboarding-primary); display: flex; flex-direction: column; - width: 450px; + width: 420px; justify-content: center; align-items: center; margin: 16px 0;