Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Add keyboard shortcut for emoji reactions #5425

Merged
merged 5 commits into from
Dec 14, 2020

Conversation

macekj
Copy link
Contributor

@macekj macekj commented Nov 17, 2020

Fixes element-hq/element-web#10343

Allows for users to quickly react to the most recently sent message in the current room by typing + followed by an emoji into the message composer. This is a feature supported by both Discord and Slack.

ZJE0ZfLJDZ

This is my first contribution to this project, so please let me know if there is anything I need to do 😄

Signed-off-by: Joe Macek macekj@umich.edu

Signed-off-by: macekj <macekj@umich.edu>
@t3chguy t3chguy requested a review from a team November 17, 2020 22:58
@t3chguy
Copy link
Member

t3chguy commented Nov 17, 2020

Very interesting!

@turt2live turt2live requested a review from a team November 20, 2020 16:14
@turt2live turt2live added the Z-Community-PR Issue is solved by a community member's PR label Nov 20, 2020
@ara4n
Copy link
Member

ara4n commented Nov 24, 2020

featureswise/designwise this is great - lgtm :)

@@ -47,7 +47,7 @@ import AutocompleteWrapperModel from "../../../editor/autocomplete";
import DocumentPosition from "../../../editor/position";
import {ICompletion} from "../../../autocomplete/Autocompleter";

const REGEX_EMOTICON_WHITESPACE = new RegExp('(?:^|\\s)(' + EMOTICON_REGEX.source + ')\\s$');
const REGEX_EMOTICON_WHITESPACE = new RegExp('(?:^|\\s|(?<=^\\+))(' + EMOTICON_REGEX.source + ')\\s$');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this regexp is getting quite impenetrable now :) can we comment it?

// match emoticons which follow the start of a line, whitespace, a plus at the start of a line.

I'm a bit unclear on why we need the nested positive look-behind assertion here - plus it looks like the (?<=) will act as a capturing group, which might have undesirable side-effects given the wrapping group is a non-capturing (?:). Does (?:^|\\s|^\\+) work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! I've gone ahead and commented it as well as removed the lookbehind and it is still working as intended.

I think the negative lookbehind is still necessary for the EmojiProvider regex. Otherwise, the entire match gets replaced when autocompleting an emoji suggestion ("+:gleeful" gets sent to "😃" instead of "+😃"). Unless there is a different way to do it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for this (and thanks for the PR!). I guess a similar clarification is needed for EMOJI_REGEX then to comment why the lookbehind is needed there but not here?

otherwise this lgtm, but i'll defer to @jryans & co for formal review from the eleweb team.

Signed-off-by: macekj <macekj@umich.edu>
@turt2live turt2live requested review from a team and removed request for a team November 24, 2020 16:44
@jryans jryans requested review from jryans and bwindels and removed request for a team November 26, 2020 14:10
jryans
jryans previously requested changes Nov 26, 2020
Copy link
Collaborator

@jryans jryans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable overall, thanks for working on this! 😄 I'd like @bwindels to take a look particularly at the editor changes, as he's the expert in that area.

src/autocomplete/EmojiProvider.tsx Outdated Show resolved Hide resolved
Signed-off-by: macekj <macekj@umich.edu>
@macekj
Copy link
Contributor Author

macekj commented Nov 28, 2020

I did some more digging and testing with the regexes and it turns out that neither of them actually play into the autocompletion, and the feature works as intended without having modified either regex! I must have changed them early on thinking it would be necessary, but it looks like the only necessary change is looking for a "+" in tabCompleteName.

Hopefully this is more clear. Thank you for the feedback so far!

Copy link
Contributor

@bwindels bwindels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! Just a few comments on functions that can be reused.

@bwindels bwindels self-requested a review December 4, 2020 14:55
Copy link
Contributor

@bwindels bwindels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes, lgtm!

@jryans jryans dismissed their stale review December 4, 2020 14:57

Outdated

@jryans
Copy link
Collaborator

jryans commented Dec 4, 2020

@macekj I think the only step remaining is to get tests to pass. I think the error is unrelated to your changes, and will be fixed if you merge in the latest changes from the develop branch.

@macekj
Copy link
Contributor Author

macekj commented Dec 13, 2020

Doing a gentle bump -- I merged from develop last week, if there's anything else I need to do just let me know! 😄

@jryans
Copy link
Collaborator

jryans commented Dec 14, 2020

Thanks for the comment! (Do feel free to message on a PR like you did and / or in #element-dev wherever it feels like things have been stuck for several days, as it may have just gotten stuck in the tubes full of GH notifications.) 😄

Looks like we're all ready to go here, so let's merge! Thanks again for working on this! 😄

@pdurbin
Copy link

pdurbin commented Feb 1, 2023

A follow up issue to document this awesome shortcut:

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Z-Community-PR Issue is solved by a community member's PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Keyboard shortcut for emoji reactions
7 participants