Skip to content

Commit

Permalink
Check whether the editor is ready only for the upgrade button
Browse files Browse the repository at this point in the history
  • Loading branch information
arthur791004 committed Oct 24, 2024
1 parent d41a6b9 commit dd6137c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { usePreviewingThemeSlug } from './hooks/use-previewing-theme';
import LivePreviewNoticePlugin from './live-preview-notice-plugin';

const LivePreviewPlugin = () => {
const isReady = useSelect( ( select ) => select( 'core/editor' ).__unstableIsEditorReady() );
const siteEditorStore = useSelect( ( select ) => select( 'core/edit-site' ), [] );
const previewingThemeSlug = usePreviewingThemeSlug();

Expand All @@ -14,11 +13,6 @@ const LivePreviewPlugin = () => {
return null;
}

// Don't render until the editor is ready
if ( ! isReady ) {
return null;
}

// Don't render unless the user is previewing a theme.
if ( ! previewingThemeSlug ) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const LivePreviewNotice: FC< {
};

const LivePreviewNoticePlugin = () => {
const isReady = useSelect( ( select ) => select( 'core/editor' ).__unstableIsEditorReady() );
const siteEditorStore = useSelect( ( select ) => select( 'core/edit-site' ), [] );
const previewingTheme = usePreviewingTheme();
const { canPreviewButNeedUpgrade, upgradePlan } = useCanPreviewButNeedUpgrade( previewingTheme );
Expand All @@ -72,7 +73,7 @@ const LivePreviewNoticePlugin = () => {
if ( canPreviewButNeedUpgrade ) {
return (
<>
<LivePreviewUpgradeButton { ...{ previewingTheme, upgradePlan } } />
{ isReady && <LivePreviewUpgradeButton { ...{ previewingTheme, upgradePlan } } /> }
<LivePreviewUpgradeNotice { ...{ previewingTheme, dashboardLink } } />
</>
);
Expand Down

0 comments on commit dd6137c

Please sign in to comment.