From 5d19a868887fc87744de43839b2c9d85fba028e1 Mon Sep 17 00:00:00 2001 From: Kerry Liu Date: Wed, 5 May 2021 09:09:57 -0700 Subject: [PATCH] Persist mailto, tel and internal types --- packages/block-library/src/navigation-link/edit.js | 3 ++- packages/block-library/src/navigation-link/test/edit.js | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/navigation-link/edit.js b/packages/block-library/src/navigation-link/edit.js index 7cfb26bd83482d..d44e0870093a6c 100644 --- a/packages/block-library/src/navigation-link/edit.js +++ b/packages/block-library/src/navigation-link/edit.js @@ -189,6 +189,7 @@ export const updateNavigationLinkBlockAttributes = ( ? escape( title ) : originalLabel || escape( normalizedURL ); + // In https://github.com/WordPress/gutenberg/pull/24670 we decided to use "tag" in favor of "post_tag" const type = newType === 'post_tag' ? 'tag' : newType.replace( '-', '_' ); const isBuiltInType = @@ -204,7 +205,7 @@ export const updateNavigationLinkBlockAttributes = ( ...( undefined !== opensInNewTab && { opensInNewTab } ), ...( id && Number.isInteger( id ) && { id } ), ...( kind && { kind } ), - ...( type && ! isCustomLink && { type } ), + ...( type && type !== 'URL' && { type } ), } ); }; diff --git a/packages/block-library/src/navigation-link/test/edit.js b/packages/block-library/src/navigation-link/test/edit.js index 23e5d94a332c14..331ff62d4197c7 100644 --- a/packages/block-library/src/navigation-link/test/edit.js +++ b/packages/block-library/src/navigation-link/test/edit.js @@ -259,6 +259,7 @@ describe( 'edit', () => { label: 'mailto:foo@example.com', kind: 'custom', url: 'mailto:foo@example.com', + type: 'mailto', } ); } ); @@ -280,6 +281,7 @@ describe( 'edit', () => { label: '#foo', kind: 'custom', url: '#foo', + type: 'internal', } ); } ); @@ -301,6 +303,7 @@ describe( 'edit', () => { label: 'tel:5555555', kind: 'custom', url: 'tel:5555555', + type: 'tel', } ); } ); } );