Skip to content

Commit

Permalink
Site Editor: Avoid using edited post selectors in welcome guide (#66926)
Browse files Browse the repository at this point in the history
Co-authored-by: youknowriad <[email protected]>
Co-authored-by: ntsekouras <[email protected]>
  • Loading branch information
3 people authored Nov 12, 2024
1 parent e07351b commit f3e8f4a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
8 changes: 7 additions & 1 deletion packages/edit-site/src/components/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,13 @@ export default function EditSiteEditor( { isPostsList = false } ) {
<EditorKeyboardShortcutsRegister />
{ isEditMode && <BlockKeyboardShortcuts /> }
{ ! isReady ? <CanvasLoader id={ loadingProgressId } /> : null }
{ isEditMode && <WelcomeGuide /> }
{ isEditMode && (
<WelcomeGuide
postType={
postWithTemplate ? contextPostType : editedPostType
}
/>
) }
{ isReady && (
<Editor
postType={
Expand Down
6 changes: 3 additions & 3 deletions packages/edit-site/src/components/welcome-guide/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import WelcomeGuideStyles from './styles';
import WelcomeGuidePage from './page';
import WelcomeGuideTemplate from './template';

export default function WelcomeGuide() {
export default function WelcomeGuide( { postType } ) {
return (
<>
<WelcomeGuideEditor />
<WelcomeGuideStyles />
<WelcomeGuidePage />
<WelcomeGuideTemplate />
{ postType === 'page' && <WelcomeGuidePage /> }
{ postType === 'wp_template' && <WelcomeGuideTemplate /> }
</>
);
}
8 changes: 1 addition & 7 deletions packages/edit-site/src/components/welcome-guide/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ import { Guide } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { store as preferencesStore } from '@wordpress/preferences';

/**
* Internal dependencies
*/
import { store as editSiteStore } from '../../store';

export default function WelcomeGuidePage() {
const { toggle } = useDispatch( preferencesStore );

Expand All @@ -23,8 +18,7 @@ export default function WelcomeGuidePage() {
'core/edit-site',
'welcomeGuide'
);
const { isPage } = select( editSiteStore );
return isPageActive && ! isEditorActive && isPage();
return isPageActive && ! isEditorActive;
}, [] );

if ( ! isVisible ) {
Expand Down
9 changes: 1 addition & 8 deletions packages/edit-site/src/components/welcome-guide/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,9 @@ import { __ } from '@wordpress/i18n';
import { store as preferencesStore } from '@wordpress/preferences';
import { store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
*/
import useEditedEntityRecord from '../use-edited-entity-record';

export default function WelcomeGuideTemplate() {
const { toggle } = useDispatch( preferencesStore );

const { isLoaded, record } = useEditedEntityRecord();
const isPostTypeTemplate = isLoaded && record.type === 'wp_template';
const { isActive, hasPreviousEntity } = useSelect( ( select ) => {
const { getEditorSettings } = select( editorStore );
const { get } = select( preferencesStore );
Expand All @@ -26,7 +19,7 @@ export default function WelcomeGuideTemplate() {
!! getEditorSettings().onNavigateToPreviousEntityRecord,
};
}, [] );
const isVisible = isActive && isPostTypeTemplate && hasPreviousEntity;
const isVisible = isActive && hasPreviousEntity;

if ( ! isVisible ) {
return null;
Expand Down

0 comments on commit f3e8f4a

Please sign in to comment.