diff --git a/packages/block-library/src/navigation-link/edit.js b/packages/block-library/src/navigation-link/edit.js index 9e2e171975570..57ac7c24b60e7 100644 --- a/packages/block-library/src/navigation-link/edit.js +++ b/packages/block-library/src/navigation-link/edit.js @@ -158,7 +158,7 @@ function getMissingText( type ) { * packages/block-library/src/navigation-submenu/edit.js * Consider reuseing this components for both blocks. */ -function Controls( { attributes, setAttributes, setIsLabelFieldFocused } ) { +function Controls( { attributes, setAttributes } ) { const { label, url, description, title, rel } = attributes; return ( @@ -171,8 +171,6 @@ function Controls( { attributes, setAttributes, setIsLabelFieldFocused } ) { } } label={ __( 'Text' ) } autoComplete="off" - onFocus={ () => setIsLabelFieldFocused( true ) } - onBlur={ () => setIsLabelFieldFocused( false ) } />
@@ -499,51 +492,47 @@ export default function NavigationLinkEdit( {
) : ( <> - { ! isInvalid && - ! isDraft && - ! isLabelFieldFocused && ( - <> - - setAttributes( { - label: labelValue, - } ) - } - onMerge={ mergeBlocks } - onReplace={ onReplace } - __unstableOnSplitAtEnd={ () => - insertBlocksAfter( - createBlock( - 'core/navigation-link' - ) + { ! isInvalid && ! isDraft && ( + <> + + setAttributes( { + label: labelValue, + } ) + } + onMerge={ mergeBlocks } + onReplace={ onReplace } + __unstableOnSplitAtEnd={ () => + insertBlocksAfter( + createBlock( + 'core/navigation-link' ) - } - aria-label={ __( - 'Navigation link text' - ) } - placeholder={ itemLabelPlaceholder } - withoutInteractiveFormatting - allowedFormats={ [ - 'core/bold', - 'core/italic', - 'core/image', - 'core/strikethrough', - ] } - /> - { description && ( - - { description } - + ) + } + aria-label={ __( + 'Navigation link text' ) } - - ) } - { ( isInvalid || - isDraft || - isLabelFieldFocused ) && ( + placeholder={ itemLabelPlaceholder } + withoutInteractiveFormatting + allowedFormats={ [ + 'core/bold', + 'core/italic', + 'core/image', + 'core/strikethrough', + ] } + /> + { description && ( + + { description } + + ) } + + ) } + { ( isInvalid || isDraft ) && (
0 ) { // If the to be added range and the live range are the same, there's no @@ -287,7 +291,10 @@ export function applySelection( { startPath, endPath }, current ) { // This function is not intended to cause a shift in focus. Since the above // selection manipulations may shift focus, ensure that focus is restored to // its previous state. - if ( activeElement !== ownerDocument.activeElement ) { + // Do not take focus if user is not in iFrame editing canvas. + // + // See: https://github.com/WordPress/gutenberg/issues/61315 + if ( isInsideFrame && activeElement !== ownerDocument.activeElement ) { // The `instanceof` checks protect against edge cases where the focused // element is not of the interface HTMLElement (does not have a `focus` // or `blur` property).