Skip to content

Commit

Permalink
Remove Create option from initial suggestions
Browse files Browse the repository at this point in the history
Addresses #18900 (comment)

If we need to reinstate this functionality we can simply revert this commit.
  • Loading branch information
getdave committed Feb 10, 2020
1 parent 2295338 commit 170efd6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/block-editor/src/components/link-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ function LinkControl( {

const directLinkEntryTypes = [ 'url', 'mailto', 'tel', 'internal' ];
const isSingleDirectEntryResult = suggestions.length === 1 && directLinkEntryTypes.includes( suggestions[ 0 ].type.toLowerCase() );
const shouldShowCreateEntity = showCreateEntity && createEntity && ! isSingleDirectEntryResult;
const shouldShowCreateEntity = showCreateEntity && createEntity && ! isSingleDirectEntryResult && ! isInitialSuggestions;
: undefined;
const labelText = isInitialSuggestions
? __( 'Recently updated' )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {
expect( currentLinkHTML ).toEqual( expect.stringContaining( '/?p=123' ) ); // slug
} );

it( 'should show option to create "blank" entity in initial suggestions (when input is empty)', async () => {
it( 'should show not show an option to create "blank" entity in initial suggestions (when input is empty)', async () => {
act( () => {
render(
<LinkControl
Expand Down Expand Up @@ -598,8 +598,7 @@ describe( 'Creating Entities (eg: Posts, Pages)', () => {

// Verify input has no value
expect( searchInput.value ).toBe( '' );
expect( createButton ).not.toBeNull();
expect( createButton.innerHTML ).toEqual( expect.stringContaining( 'Create new' ) );
expect( createButton ).toBeNull(); // shouldn't exist!
} );

it.each( [
Expand Down

0 comments on commit 170efd6

Please sign in to comment.