-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Site Editor: Do not display 'trashed' navigation menus in Sidebar (#5…
…5072) * Site Editor: Do not display 'trashed' navigation menus in Sidebar * Extract selector into a hook Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> --------- Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com>
- Loading branch information
1 parent
b3d28f9
commit af6cb47
Showing
3 changed files
with
36 additions
and
15 deletions.
There are no files selected for viewing
9 changes: 2 additions & 7 deletions
9
...c/components/sidebar-navigation-screen-pattern/template-part-navigation-menu-list-item.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...s/edit-site/src/components/sidebar-navigation-screen-pattern/use-navigation-menu-title.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useSelect } from '@wordpress/data'; | ||
import { store as coreStore } from '@wordpress/core-data'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { NAVIGATION_POST_TYPE } from '../../utils/constants'; | ||
|
||
export default function useNavigationMenuTitle( id ) { | ||
return useSelect( | ||
( select ) => { | ||
if ( ! id ) { | ||
return undefined; | ||
} | ||
|
||
const editedRecord = select( coreStore ).getEditedEntityRecord( | ||
'postType', | ||
NAVIGATION_POST_TYPE, | ||
id | ||
); | ||
|
||
// Do not display a 'trashed' navigation menu. | ||
return editedRecord.status === 'trash' | ||
? undefined | ||
: editedRecord.title; | ||
}, | ||
[ id ] | ||
); | ||
} |