diff --git a/packages/block-library/src/navigation-link/update-attributes.js b/packages/block-library/src/navigation-link/update-attributes.js index 6aa28d1818d3cc..050a259d394712 100644 --- a/packages/block-library/src/navigation-link/update-attributes.js +++ b/packages/block-library/src/navigation-link/update-attributes.js @@ -86,12 +86,13 @@ export const updateAttributes = ( ( ! newKind && ! isBuiltInType ) || newKind === 'custom'; const kind = isCustomLink ? 'custom' : newKind; + const hasId = id && Number.isInteger( id ); + setAttributes( { - // Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string. ...( newUrl && { url: encodeURI( safeDecodeURI( newUrl ) ) } ), ...( label && { label } ), ...( undefined !== opensInNewTab && { opensInNewTab } ), - ...( id && Number.isInteger( id ) && { id } ), + ...( hasId && { id } ), ...( kind && { kind } ), ...( type && type !== 'URL' && { type } ), } );