Skip to content

Commit

Permalink
Bundle the block selection clearer hook into the BlockCanvas component (
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad authored Sep 6, 2023
1 parent 62b8de2 commit 29a8001
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 30 deletions.
8 changes: 7 additions & 1 deletion packages/block-editor/src/components/block-canvas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Iframe from '../iframe';
import WritingFlow from '../writing-flow';
import { useMouseMoveTypingReset } from '../observe-typing';
import { useClipboardHandler } from '../copy-handler';
import { useBlockSelectionClearer } from '../block-selection-clearer';

export function ExperimentalBlockCanvas( {
shouldIframe = true,
Expand All @@ -23,7 +24,12 @@ export function ExperimentalBlockCanvas( {
} ) {
const resetTypingRef = useMouseMoveTypingReset();
const copyHandler = useClipboardHandler();
const contentRef = useMergeRefs( [ copyHandler, contentRefProp ] );
const clearerRef = useBlockSelectionClearer();
const contentRef = useMergeRefs( [
copyHandler,
contentRefProp,
clearerRef,
] );

if ( ! shouldIframe ) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { useMemo, createPortal } from '@wordpress/element';
import {
BlockList,
BlockTools,
BlockSelectionClearer,
BlockInspector,
privateApis as blockEditorPrivateApis,
__unstableBlockSettingsMenuFirstItem,
Expand Down Expand Up @@ -114,15 +113,13 @@ export default function SidebarBlockEditor( {
/>

<BlockTools>
<BlockSelectionClearer>
<BlockCanvas
shouldIframe={ false }
styles={ settings.defaultEditorStyles }
height="100%"
>
<BlockList renderAppender={ BlockAppender } />
</BlockCanvas>
</BlockSelectionClearer>
<BlockCanvas
shouldIframe={ false }
styles={ settings.defaultEditorStyles }
height="100%"
>
<BlockList renderAppender={ BlockAppender } />
</BlockCanvas>
</BlockTools>

{ createPortal(
Expand Down
10 changes: 1 addition & 9 deletions packages/edit-post/src/components/visual-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
BlockList,
BlockTools,
store as blockEditorStore,
__unstableUseBlockSelectionClearer as useBlockSelectionClearer,
__unstableUseTypewriter as useTypewriter,
__unstableUseTypingObserver as useTypingObserver,
__experimentalUseResizeCanvas as useResizeCanvas,
Expand Down Expand Up @@ -182,13 +181,7 @@ export default function VisualEditor( { styles } ) {
}

const ref = useRef();
const contentRef = useMergeRefs( [
ref,
useTypewriter(),
useBlockSelectionClearer(),
] );

const blockSelectionClearerRef = useBlockSelectionClearer();
const contentRef = useMergeRefs( [ ref, useTypewriter() ] );

// fallbackLayout is used if there is no Post Content,
// and for Post Title.
Expand Down Expand Up @@ -322,7 +315,6 @@ export default function VisualEditor( { styles } ) {
animate={ {
padding: isTemplateMode ? '48px 48px 0' : 0,
} }
ref={ blockSelectionClearerRef }
>
<motion.div
animate={ animatedStyles }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import {
BlockList,
BlockTools,
BlockSelectionClearer,
privateApis as blockEditorPrivateApis,
} from '@wordpress/block-editor';
import { useSelect } from '@wordpress/data';
Expand Down Expand Up @@ -43,15 +42,13 @@ export default function WidgetAreasBlockEditorContent( {
<Notices />
<BlockTools>
<KeyboardShortcuts />
<BlockSelectionClearer>
<BlockCanvas
shouldIframe={ false }
styles={ styles }
height="100%"
>
<BlockList className="edit-widgets-main-block-list" />
</BlockCanvas>
</BlockSelectionClearer>
<BlockCanvas
shouldIframe={ false }
styles={ styles }
height="100%"
>
<BlockList className="edit-widgets-main-block-list" />
</BlockCanvas>
</BlockTools>
</div>
);
Expand Down

1 comment on commit 29a8001

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 29a8001.
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/6097118866
📝 Reported issues:

Please sign in to comment.