Skip to content

Commit

Permalink
Navigation Link UI: Remove onClose from onSelectBlock (#67760)
Browse files Browse the repository at this point in the history
onSelectBlock was being called after from the QuickInserter even if the link ui had already been closed. This results in some weird states due to the function containing old states. There have been updates to this flow around closing the link ui since the code was originally written, and the onClose should be handled by the popover already.

Co-authored-by: jeryj <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: darnado <[email protected]>
  • Loading branch information
4 people authored Jan 14, 2025
1 parent 130b6e2 commit 1623711
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions packages/block-library/src/navigation-link/link-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function getSuggestionsQuery( type, kind ) {
}
}

function LinkUIBlockInserter( { clientId, onBack, onSelectBlock } ) {
function LinkUIBlockInserter( { clientId, onBack } ) {
const { rootBlockClientId } = useSelect(
( select ) => {
const { getBlockRootClientId } = select( blockEditorStore );
Expand Down Expand Up @@ -140,7 +140,6 @@ function LinkUIBlockInserter( { clientId, onBack, onSelectBlock } ) {
prioritizePatterns={ false }
selectBlockOnInsert
hasSearch={ false }
onSelect={ onSelectBlock }
/>
</div>
);
Expand Down Expand Up @@ -203,10 +202,6 @@ function UnforwardedLinkUI( props, ref ) {
`link-ui-link-control__description`
);

// Selecting a block should close the popover and also remove the (previously) automatically inserted
// link block so that the newly selected block can be inserted in its place.
const { onClose: onSelectBlock } = props;

return (
<Popover
ref={ ref }
Expand Down Expand Up @@ -287,7 +282,6 @@ function UnforwardedLinkUI( props, ref ) {
setAddingBlock( false );
setFocusAddBlockButton( true );
} }
onSelectBlock={ onSelectBlock }
/>
) }
</Popover>
Expand Down

0 comments on commit 1623711

Please sign in to comment.