-
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.
Navigation editor: Fix content mode (#56856)
- Loading branch information
1 parent
7bdc190
commit 3514f11
Showing
2 changed files
with
41 additions
and
34 deletions.
There are no files selected for viewing
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
37 changes: 37 additions & 0 deletions
37
packages/editor/src/components/provider/navigation-block-editing-mode.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,37 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useEffect } from '@wordpress/element'; | ||
import { useDispatch, useSelect } from '@wordpress/data'; | ||
import { store as blockEditorStore } from '@wordpress/block-editor'; | ||
|
||
/** | ||
* For the Navigation block editor, we need to force the block editor to contentOnly for that block. | ||
* | ||
* Set block editing mode to contentOnly when entering Navigation focus mode. | ||
* this ensures that non-content controls on the block will be hidden and thus | ||
* the user can focus on editing the Navigation Menu content only. | ||
*/ | ||
|
||
export default function NavigationBlockEditingMode() { | ||
// In the navigation block editor, | ||
// the navigation block is the only root block. | ||
const blockClientId = useSelect( | ||
( select ) => select( blockEditorStore ).getBlockOrder()?.[ 0 ], | ||
[] | ||
); | ||
const { setBlockEditingMode, unsetBlockEditingMode } = | ||
useDispatch( blockEditorStore ); | ||
|
||
useEffect( () => { | ||
if ( ! blockClientId ) { | ||
return; | ||
} | ||
|
||
setBlockEditingMode( blockClientId, 'contentOnly' ); | ||
|
||
return () => { | ||
unsetBlockEditingMode( blockClientId ); | ||
}; | ||
}, [ blockClientId, unsetBlockEditingMode, setBlockEditingMode ] ); | ||
} |
3514f11
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flaky tests detected in 3514f11.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7127938411
📝 Reported issues:
/test/e2e/specs/site-editor/font-library.spec.js