Skip to content

Commit

Permalink
navigation-link: calling setter once
Browse files Browse the repository at this point in the history
  • Loading branch information
retrofox committed Nov 21, 2019
1 parent a8ffdfd commit b5e12fc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/block-library/src/navigation-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@ const updateLinkSetting = ( setter ) => ( setting, value ) => {
* @param {string} label Link label.
*/
const updateLink = ( setter, label ) => ( { title: newTitle = '', url: newURL = '', id = -1 } = {} ) => {
setter( { title: newTitle, url: newURL, id } );
const linkSetting = { title: newTitle, url: newURL, id };

// Set the item label as well if it isn't already defined.
if ( ! label ) {
setter( { label: newTitle } );
linkSetting.label = newTitle;
}

setter( linkSetting );
};

function NavigationLinkEdit( {
Expand Down

0 comments on commit b5e12fc

Please sign in to comment.