Skip to content

Commit

Permalink
Insert @username for user mention autocomplete (#4444)
Browse files Browse the repository at this point in the history
Rather than inserting a static link and the display name, both of which may change over time and lead to stale content, follow the pattern of existing user mentions in WordPress projects and insert a plaintext mention using the username.
  • Loading branch information
helen authored and pento committed Jan 16, 2018
1 parent 2e276ad commit 7f7b607
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions blocks/autocompleters/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export function blockAutocompleter( { onReplace } ) {
};
}
/**
* Returns a "completer" definition for inserting links to the posts of a user.
* Returns a "completer" definition for inserting a user mention.
* The definition can be understood by the Autocomplete component.
*
* @returns {Completer} Completer object used by the Autocomplete component.
Expand All @@ -123,12 +123,12 @@ export function userAutocompleter() {
} );
};

const allowNode = ( textNode ) => {
return textNode.parentElement.closest( 'a' ) === null;
const allowNode = () => {
return true;
};

const onSelect = ( user ) => {
return <a href={ user.link }>{ '@' + user.name }</a>;
return ( '@' + user.slug );
};

return {
Expand Down

0 comments on commit 7f7b607

Please sign in to comment.