From 09747dd98ab171d27fc79575fc51e017f96a9af2 Mon Sep 17 00:00:00 2001 From: Rostislav Wolny Date: Thu, 19 Dec 2024 10:04:57 +0100 Subject: [PATCH] Update start from scratch and close to use the first template + pattern [MAILPOET-6334] --- .../template-select/select-modal.tsx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/js/email-editor/src/components/template-select/select-modal.tsx b/packages/js/email-editor/src/components/template-select/select-modal.tsx index 8a6e52a4b4..5830f2ac7f 100644 --- a/packages/js/email-editor/src/components/template-select/select-modal.tsx +++ b/packages/js/email-editor/src/components/template-select/select-modal.tsx @@ -1,8 +1,15 @@ +/** + * WordPress dependencies + */ import { useState, useEffect, memo } from '@wordpress/element'; import { store as editorStore } from '@wordpress/editor'; import { dispatch } from '@wordpress/data'; import { Modal, Button, Flex, FlexItem } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; + +/** + * Internal dependencies + */ import { usePreviewTemplates } from '../../hooks'; import { EmailEditorPostType, @@ -13,8 +20,6 @@ import { import { TemplateList } from './template-list'; import { TemplateCategoriesListSidebar } from './template-categories-list-sidebar'; -const BLANK_TEMPLATE = 'email-general'; - const TemplateCategories: Array< { name: TemplateCategory; label: string } > = [ { name: 'recent', @@ -91,13 +96,11 @@ export function SelectTemplateModal( { }; const handleCloseWithoutSelection = () => { - const blankTemplate = templates.find( - ( template ) => template.slug === BLANK_TEMPLATE - ) as unknown as TemplatePreview; - if ( ! blankTemplate ) { + const template = templates[ 0 ] ?? null; + if ( ! template ) { return; - } // Prevent close if blank template is still not loaded - handleTemplateSelection( blankTemplate ); + } // Prevent closing when templates are not loaded + handleTemplateSelection( template ); }; return (