Skip to content

Commit

Permalink
Persist mailto, tel and internal types
Browse files Browse the repository at this point in the history
  • Loading branch information
gwwar committed May 5, 2021
1 parent c6a8a59 commit 5d19a86
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/block-library/src/navigation-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -204,7 +205,7 @@ export const updateNavigationLinkBlockAttributes = (
...( undefined !== opensInNewTab && { opensInNewTab } ),
...( id && Number.isInteger( id ) && { id } ),
...( kind && { kind } ),
...( type && ! isCustomLink && { type } ),
...( type && type !== 'URL' && { type } ),
} );
};

Expand Down
3 changes: 3 additions & 0 deletions packages/block-library/src/navigation-link/test/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ describe( 'edit', () => {
label: 'mailto:foo@example.com',
kind: 'custom',
url: 'mailto:foo@example.com',
type: 'mailto',
} );
} );

Expand All @@ -280,6 +281,7 @@ describe( 'edit', () => {
label: '#foo',
kind: 'custom',
url: '#foo',
type: 'internal',
} );
} );

Expand All @@ -301,6 +303,7 @@ describe( 'edit', () => {
label: 'tel:5555555',
kind: 'custom',
url: 'tel:5555555',
type: 'tel',
} );
} );
} );
Expand Down

0 comments on commit 5d19a86

Please sign in to comment.