Skip to content

Commit

Permalink
Site Editor: Remove useless onClick handler
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed May 23, 2024
1 parent f49e0b5 commit ae373f9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 29 deletions.
14 changes: 2 additions & 12 deletions packages/edit-site/src/components/block-editor/editor-canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,7 @@ import {

const { EditorCanvas: EditorCanvasRoot } = unlock( editorPrivateApis );

function EditorCanvas( {
enableResizing,
settings,
children,
onClick,
...props
} ) {
function EditorCanvas( { enableResizing, settings, children, ...props } ) {
const {
hasBlocks,
isFocusMode,
Expand Down Expand Up @@ -88,11 +82,7 @@ function EditorCanvas( {
}
},
onClick: () => {
if ( !! onClick ) {
onClick();
} else {
setCanvasMode( 'edit' );
}
setCanvasMode( 'edit' );
},
onClickCapture: ( event ) => {
if ( currentPostIsTrashed ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { privateApis as routerPrivateApis } from '@wordpress/router';

const { useLocation } = unlock( routerPrivateApis );

export default function SiteEditorCanvas( { onClick } ) {
export default function SiteEditorCanvas() {
const location = useLocation();
const { templateType, isFocusableEntity, isViewMode, isZoomOutMode } =
useSelect( ( select ) => {
Expand Down Expand Up @@ -89,7 +89,6 @@ export default function SiteEditorCanvas( { onClick } ) {
<EditorCanvas
enableResizing={ enableResizing }
settings={ settings }
onClick={ onClick }
>
{
// Avoid resize listeners when not needed,
Expand Down
6 changes: 2 additions & 4 deletions packages/edit-site/src/components/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const interfaceLabels = {

const ANIMATION_DURATION = 0.25;

export default function Editor( { isLoading, onClick } ) {
export default function Editor( { isLoading } ) {
const {
record: editedPost,
getTitle,
Expand Down Expand Up @@ -351,9 +351,7 @@ export default function Editor( { isLoading, onClick } ) {
{ ! isLargeViewport && showVisualEditor && (
<BlockToolbar hideDragHandle />
) }
{ showVisualEditor && (
<SiteEditorCanvas onClick={ onClick } />
) }
{ showVisualEditor && <SiteEditorCanvas /> }
</>
}
secondarySidebar={
Expand Down
12 changes: 1 addition & 11 deletions packages/edit-site/src/components/layout/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ function useRedirectOldPaths() {

export default function useLayoutAreas() {
const isSiteEditorLoading = useIsSiteEditorLoading();
const history = useHistory();
const { params } = useLocation();
const { postType, postId, path, layout, isCustom, canvas } = params;
useRedirectOldPaths();
Expand All @@ -95,16 +94,7 @@ export default function useLayoutAreas() {
),
content: <PagePages />,
preview: ( isListLayout || canvas === 'edit' ) && (
<Editor
isLoading={ isSiteEditorLoading }
onClick={ () =>
history.push( {
postType: 'page',
postId,
canvas: 'edit',
} )
}
/>
<Editor isLoading={ isSiteEditorLoading } />
),
mobile:
canvas === 'edit' ? (
Expand Down

0 comments on commit ae373f9

Please sign in to comment.