diff --git a/packages/edit-post/src/components/editor-initialization/index.js b/packages/edit-post/src/components/editor-initialization/index.js
index 0ba9cc863f473f..bf61d569fc81c8 100644
--- a/packages/edit-post/src/components/editor-initialization/index.js
+++ b/packages/edit-post/src/components/editor-initialization/index.js
@@ -10,11 +10,10 @@ import {
* Data component used for initializing the editor and re-initializes
* when postId changes or on unmount.
*
- * @param {number} postId The id of the post.
* @return {null} This is a data component so does not render any ui.
*/
-export default function EditorInitialization( { postId } ) {
- useBlockSelectionListener( postId );
- useUpdatePostLinkListener( postId );
+export default function EditorInitialization() {
+ useBlockSelectionListener();
+ useUpdatePostLinkListener();
return null;
}
diff --git a/packages/edit-post/src/components/editor-initialization/listener-hooks.js b/packages/edit-post/src/components/editor-initialization/listener-hooks.js
index 73872b4d7110e4..a5534135f9cfb8 100644
--- a/packages/edit-post/src/components/editor-initialization/listener-hooks.js
+++ b/packages/edit-post/src/components/editor-initialization/listener-hooks.js
@@ -19,24 +19,19 @@ import {
/**
* This listener hook monitors for block selection and triggers the appropriate
* sidebar state.
- *
- * @param {number} postId The current post id.
*/
-export const useBlockSelectionListener = ( postId ) => {
+export const useBlockSelectionListener = () => {
const { hasBlockSelection, isEditorSidebarOpened, isDistractionFree } =
- useSelect(
- ( select ) => {
- const { get } = select( preferencesStore );
- return {
- hasBlockSelection:
- !! select( blockEditorStore ).getBlockSelectionStart(),
- isEditorSidebarOpened:
- select( STORE_NAME ).isEditorSidebarOpened(),
- isDistractionFree: get( 'core', 'distractionFree' ),
- };
- },
- [ postId ]
- );
+ useSelect( ( select ) => {
+ const { get } = select( preferencesStore );
+ return {
+ hasBlockSelection:
+ !! select( blockEditorStore ).getBlockSelectionStart(),
+ isEditorSidebarOpened:
+ select( STORE_NAME ).isEditorSidebarOpened(),
+ isDistractionFree: get( 'core', 'distractionFree' ),
+ };
+ }, [] );
const { openGeneralSidebar } = useDispatch( STORE_NAME );
@@ -49,21 +44,24 @@ export const useBlockSelectionListener = ( postId ) => {
} else {
openGeneralSidebar( 'edit-post/document' );
}
- }, [ hasBlockSelection, isEditorSidebarOpened ] );
+ }, [
+ hasBlockSelection,
+ isDistractionFree,
+ isEditorSidebarOpened,
+ openGeneralSidebar,
+ ] );
};
/**
* This listener hook monitors any change in permalink and updates the view
* post link in the admin bar.
- *
- * @param {number} postId
*/
-export const useUpdatePostLinkListener = ( postId ) => {
+export const useUpdatePostLinkListener = () => {
const { newPermalink } = useSelect(
( select ) => ( {
newPermalink: select( editorStore ).getCurrentPost().link,
} ),
- [ postId ]
+ []
);
const nodeToUpdate = useRef();
@@ -71,7 +69,7 @@ export const useUpdatePostLinkListener = ( postId ) => {
nodeToUpdate.current =
document.querySelector( VIEW_AS_PREVIEW_LINK_SELECTOR ) ||
document.querySelector( VIEW_AS_LINK_SELECTOR );
- }, [ postId ] );
+ }, [] );
useEffect( () => {
if ( ! newPermalink || ! nodeToUpdate.current ) {
diff --git a/packages/edit-post/src/components/editor-initialization/test/listener-hooks.js b/packages/edit-post/src/components/editor-initialization/test/listener-hooks.js
index 5087d303fafe1e..a294336ea1f1e9 100644
--- a/packages/edit-post/src/components/editor-initialization/test/listener-hooks.js
+++ b/packages/edit-post/src/components/editor-initialization/test/listener-hooks.js
@@ -88,14 +88,14 @@ describe( 'listener hook tests', () => {
} );
describe( 'useBlockSelectionListener', () => {
const registry = createRegistry( mockStores );
- const TestComponent = ( { postId } ) => {
- useBlockSelectionListener( postId );
+ const TestComponent = () => {
+ useBlockSelectionListener();
return null;
};
const TestedOutput = () => {
return (
-
+
);
};
@@ -177,14 +177,14 @@ describe( 'listener hook tests', () => {
describe( 'useUpdatePostLinkListener', () => {
const registry = createRegistry( mockStores );
- const TestComponent = ( { postId } ) => {
- useUpdatePostLinkListener( postId );
+ const TestComponent = () => {
+ useUpdatePostLinkListener();
return null;
};
- const TestedOutput = ( { postId = 10 } ) => {
+ const TestedOutput = () => {
return (
-
+
);
};
diff --git a/packages/edit-post/src/editor.js b/packages/edit-post/src/editor.js
index 6aa8c2e9a62394..23045632cfaa2e 100644
--- a/packages/edit-post/src/editor.js
+++ b/packages/edit-post/src/editor.js
@@ -106,7 +106,7 @@ function Editor( {
>
-
+