Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
19f65b1
initial draft: move navigation commands to core commands
yashjawale Aug 25, 2025
b4c4600
Merge branch 'trunk' into fix/command-palette-navigation-commands-ava…
yashjawale Aug 26, 2025
44debcf
Merge branch 'trunk' into fix/command-palette-navigation-commands-ava…
yashjawale Aug 28, 2025
c6bf218
Editor: Update command palette test for custom CSS navigation
yashjawale Aug 28, 2025
a8da2d5
Merge branch 'trunk' into fix/command-palette-navigation-commands-ava…
yashjawale Sep 3, 2025
a61d7dd
fix: move custom css commands back to edit-site
yashjawale Sep 3, 2025
dc564bd
fix: update custom CSS command label
yashjawale Sep 5, 2025
08d18c6
fix: update go to styles command label
yashjawale Sep 5, 2025
a12b460
fix: update navigation command labels with colon
yashjawale Sep 5, 2025
1b85abf
fix: move commands from separate file to existing ones
yashjawale Sep 5, 2025
652a29f
Merge branch 'trunk' into fix/command-palette-navigation-commands-ava…
yashjawale Sep 5, 2025
8fcbf58
fix: re-add global styles navigation commands to site editor
yashjawale Sep 5, 2025
24ad592
fix: remove redundant global styles navigation command from site editor
yashjawale Sep 5, 2025
44f7f04
fix: implement pages override command in site editor to resolve Menu …
yashjawale Sep 8, 2025
324876f
Merge branch 'trunk' into fix/command-palette-navigation-commands-ava…
yashjawale Sep 8, 2025
4612e34
fix: filter Pages command in site editor navigation
yashjawale Sep 8, 2025
ba25952
Revert "fix: filter Pages command in site editor navigation"
yashjawale Sep 9, 2025
8b561d7
revert: remove pages command override
yashjawale Sep 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: implement pages override command in site editor to resolve Menu …
…API conflict
  • Loading branch information
yashjawale committed Sep 8, 2025
commit 44f7f046a1103026c8ce1afca587c66846ba72ec
77 changes: 58 additions & 19 deletions packages/core-commands/src/site-editor-navigation-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,25 +338,6 @@ const getSiteEditorBasicNavigationCommands = () =>
},
} );

result.push( {
name: 'core/edit-site/open-pages',
label: __( 'Go to: Pages' ),
icon: page,
callback: ( { close } ) => {
if ( isSiteEditor ) {
history.navigate( '/page' );
} else {
document.location = addQueryArgs(
'site-editor.php',
{
p: '/page',
}
);
}
close();
},
} );

result.push( {
name: 'core/edit-site/open-templates',
label: __( 'Go to: Templates' ),
Expand All @@ -376,6 +357,7 @@ const getSiteEditorBasicNavigationCommands = () =>
},
} );
}

if ( canCreatePatterns ) {
result.push( {
name: 'core/edit-site/open-patterns',
Expand Down Expand Up @@ -418,6 +400,56 @@ const getSiteEditorBasicNavigationCommands = () =>
};
};

// Override Pages command when in site editor to avoid conflict with Menu API.
const getSiteEditorPagesOverrideCommand = () =>
function useSiteEditorPagesOverrideCommand() {
const history = useHistory();
const isSiteEditor = getPath( window.location.href )?.includes(
'site-editor.php'
);
const { isBlockBasedTheme, canCreateTemplate } = useSelect(
( select ) => {
return {
isBlockBasedTheme:
select( coreStore ).getCurrentTheme()?.is_block_theme,
canCreateTemplate: select( coreStore ).canUser( 'create', {
kind: 'postType',
name: 'wp_template',
} ),
};
},
[]
);

const commands = useMemo( () => {
// Only provide this command when in site editor and user can access it.
if (
! isSiteEditor ||
! canCreateTemplate ||
! isBlockBasedTheme
) {
return [];
}

return [
{
name: 'core/edit-site/open-pages',
label: __( 'Go to Pages' ),
icon: page,
callback: ( { close } ) => {
history.navigate( '/page' );
close();
},
},
];
}, [ history, isSiteEditor, canCreateTemplate, isBlockBasedTheme ] );

return {
commands,
isLoading: false,
};
};

export function useSiteEditorNavigationCommands() {
useCommandLoader( {
name: 'core/edit-site/navigate-pages',
Expand All @@ -440,4 +472,11 @@ export function useSiteEditorNavigationCommands() {
hook: getSiteEditorBasicNavigationCommands(),
context: 'site-editor',
} );

// Register the Pages override command to handle Menu API conflict
useCommandLoader( {
name: 'core/edit-site/open-pages',
hook: getSiteEditorPagesOverrideCommand(),
context: 'site-editor',
} );
}