Skip to content

Commit

Permalink
Focus selected block in editor canvas when clicking edit button on zo…
Browse files Browse the repository at this point in the history
…om out mode toolbar (#64725)

There is currently a focus loss when clicking the edit button on the zoom out mode toolbar. This sends focus to the contentRef, which lets writing flow handle sending the focus to the selected block.

Co-authored-by: Dave Smith <getdavemail@gmail.com>
  • Loading branch information
jeryj and getdave committed Aug 23, 2024
1 parent 7a7cdd7 commit 447293e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default function ZoomOutPopover( { clientId, __unstableContentRef } ) {
{ ...props }
>
<ZoomOutToolbar
__unstableContentRef={ __unstableContentRef }
clientId={ clientId }
rootClientId={ rootClientId }
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ import BlockMover from '../block-mover';
import Shuffle from '../block-toolbar/shuffle';
import NavigableToolbar from '../navigable-toolbar';

export default function ZoomOutToolbar( { clientId, rootClientId } ) {
export default function ZoomOutToolbar( {
clientId,
rootClientId,
__unstableContentRef,
} ) {
const selected = useSelect(
( select ) => {
const {
Expand Down Expand Up @@ -133,6 +137,7 @@ export default function ZoomOutToolbar( { clientId, rootClientId } ) {
label={ __( 'Edit' ) }
onClick={ () => {
__unstableSetEditorMode( 'edit' );
__unstableContentRef.current?.focus();
} }
/>
) }
Expand Down

0 comments on commit 447293e

Please sign in to comment.