Skip to content

Commit

Permalink
Fix template mode
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Dec 10, 2020
1 parent 0b321c9 commit d946c4c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/editor/src/components/provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function EditorProvider( {
if ( __unstableTemplate ) {
__unstableSetupTemplate( __unstableTemplate );
}
}, [ __unstableTemplate ] );
}, [ __unstableTemplate?.id ] );

if ( ! isReady ) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function useBlockEditorSettings( settings, hasTemplate ) {
// This selector is only defined on mobile.
isTitleSelected: isPostTitleSelected && isPostTitleSelected(),
};
} );
}, [] );

const { undo } = useDispatch( editorStore );

Expand Down
22 changes: 11 additions & 11 deletions packages/editor/src/components/provider/use-post-content-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@ import serializeBlocks from '../../store/utils/serialize-blocks';
* @return {Object} BlockEditorProvider props.
*/
function usePostContentEditor( postType, postId ) {
const { blocks } = useSelect(
const blocks = useSelect(
( select ) => {
const { getEditedEntityRecord } = select( coreStore );
return {
blocks: getEditedEntityRecord( 'postType', postType, postId )
.blocks,
};
return getEditedEntityRecord( 'postType', postType, postId ).blocks;
},
[ postType, postId ]
);
Expand Down Expand Up @@ -64,12 +61,15 @@ function usePostContentEditor( postType, postId ) {
[ blocks, postId, postType ]
);

const onInput = useCallback( ( newBlocks, options ) => {
onChange( newBlocks, {
...options,
__unstableShouldCreateUndoLevel: false,
} );
}, onChange );
const onInput = useCallback(
( newBlocks, options ) => {
onChange( newBlocks, {
...options,
__unstableShouldCreateUndoLevel: false,
} );
},
[ onChange ]
);

return { value: blocks, onChange, onInput };
}
Expand Down

0 comments on commit d946c4c

Please sign in to comment.