-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add UserMentionSuggestions block #24194
Conversation
|
866e350
to
bdb34af
Compare
import ExampleInput from './example-input'; | ||
import withUserMentionSuggestions from '../with-user-mention-suggestions'; | ||
|
||
const UserMentionSuggestionsExampleInput = ( { onKeyPress } ) => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we need to add an explicit displayName here for this example component too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'll only ever be used inside UserMentionSuggestionsExample
(to demonstrate how the HoC works), so should be alright without one I think.
config/test.json
Outdated
@@ -84,6 +84,7 @@ | |||
"reader/full-errors": true, | |||
"reader/list-management": false, | |||
"reader/new-post-notifications": true, | |||
"reader/user-mention-suggestions": false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably fine to enable for testing, should you want to add component tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good shout 👍
static propTypes = {}; | ||
|
||
handleKeyPress = e => { | ||
if ( e.target.value[ e.target.value.length - 1 ] === '@' ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize this is a placeholder, but I would suggest adding tests later to catch our desired cases. For example would we want word@name
to trigger a highlight vs word @name
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes here look good to me 👍
Thanks for the 👀 @gwwar! |
Adds a new block,
UserMentionSuggestions
, along with a higher-order component to wrap inputs and provide @ mention suggestions inside them.Background
We current have username suggestion for @mentions in the Editor only (implemented in #10142). This is the beginning of an effort to decouple that functionality from TinyMCE and make it usable anywhere in Calypso, including the Reader comments section and Conversations tool.
To test
Visit http://calypso.localhost:3000/devdocs/blocks/user-mention-suggestions and check your console. It doesn't do much yet :-)