Skip to content
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

[HOLD for payment 2023-01-11] Web/Desktop - Emoji Picker - Space is added after the emoji in compose box #13343

Closed
isagoico opened this issue Dec 5, 2022 · 49 comments
Assignees
Labels
Daily KSv2 Engineering Reviewing Has a PR in review

Comments

@isagoico
Copy link

isagoico commented Dec 5, 2022

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. On Web/Desktop - Navigate to a conversation
  2. Click on the emoji selector and click on any emoji

Expected Result:

The emoji should be added in the compose box without any space after the emoji

Actual Result:

Emoji is added with a space in the compose box. On desktop/web, no space should be added after adding a emoji in compose box.

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

Platform:

Where is this issue occurring?

  • Web
  • Desktop App

Version Number: v1.2.36-2

Reproducible in staging?: Yes
Reproducible in production?: Yes

Email or phone of affected tester (no customers): N/A

Logs: https://stackoverflow.com/c/expensify/questions/4856

Notes/Photos/Videos: Any additional supporting documentation
image

Expensify/Expensify Issue URL: N/A

Issue reported by: Applause
Slack conversation: N/A

View all open jobs on GitHub

@isagoico isagoico added Engineering Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Dec 5, 2022
@melvin-bot
Copy link

melvin-bot bot commented Dec 5, 2022

Triggered auto assignment to @alexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Dec 5, 2022

Triggered auto assignment to @youssef-lr (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

@isagoico
Copy link
Author

isagoico commented Dec 5, 2022

Creating this issue coming from this comment - https://github.com/Expensify/Expensify/issues/245551#issuecomment-1337440659

@s77rt
Copy link
Contributor

s77rt commented Dec 5, 2022

Not a bug, this is actually intended.

App/src/libs/EmojiUtils.js

Lines 202 to 206 in 2e69dac

// If this is the last emoji in the message and it's the end of the message so far,
// add a space after it so the user can keep typing easily.
if (i === emojiData.length - 1 && text.endsWith(emojiData[i])) {
emojiReplacement += ' ';
}

@dylanexpensify
Copy link
Contributor

@s77rt in the note above (which maybe can't be accessed given it's in a diff repo!) we are wanting to have the behavior add a space for emojis ending with a : in mobile, but not web/desktop.

@Puneet-here
Copy link
Contributor

Proposal

If we don't want the space when choosing emoji from the picker we just have to make these changes -

At message composer

addEmojiToTextBox(emoji) {

     addEmojiToTextBox(emoji) {
-        const emojiWithSpace = `${emoji} `;
         const newComment = this.comment.slice(0, this.state.selection.start)
-            + emojiWithSpace + this.comment.slice(this.state.selection.end, this.comment.length);
+            + emoji + this.comment.slice(this.state.selection.end, this.comment.length);
+        this.textInput.setNativeProps({
+            text: newComment,
+        });
         this.setState(prevState => ({
             selection: {
-                start: prevState.selection.start + emojiWithSpace.length,
-                end: prevState.selection.start + emojiWithSpace.length,
+                start: prevState.selection.start + emoji.length,
+                end: prevState.selection.start + emoji.length,
             },

At edit composer

addEmojiToTextBox(emoji) {

     addEmojiToTextBox(emoji) {
-        const emojiWithSpace = `${emoji} `;
         const newComment = this.state.draft.slice(0, this.state.selection.start)
-            + emojiWithSpace + this.state.draft.slice(this.state.selection.end, this.state.draft.length);
+            + emoji + this.state.draft.slice(this.state.selection.end, this.state.draft.length);
         this.setState(prevState => ({
             selection: {
-                start: prevState.selection.start + emojiWithSpace.length,
-                end: prevState.selection.start + emojiWithSpace.length,
+                start: prevState.selection.start + emoji.length,
+                end: prevState.selection.start + emoji.length,
             },

@allroundexperts
Copy link
Contributor

allroundexperts commented Dec 6, 2022

Proposal

In order to add space just on mobile, we can make the following changes:

diff --git a/src/libs/EmojiUtils.js b/src/libs/EmojiUtils.js
index 617c624b2..bd2a76868 100644
--- a/src/libs/EmojiUtils.js
+++ b/src/libs/EmojiUtils.js
@@ -186,9 +186,10 @@ function addToFrequentlyUsedEmojis(frequentlyUsedEmojis, newEmoji) {
 /**
  * Replace any emoji name in a text with the emoji icon
  * @param {String} text
+ * @param {Boolean} addSpace
  * @returns {String}
  */
-function replaceEmojis(text) {
+function replaceEmojis(text, addSpace = true) {
     let newText = text;
     const emojiData = text.match(CONST.REGEX.EMOJI_NAME);
     if (!emojiData || emojiData.length === 0) {
@@ -201,7 +202,7 @@ function replaceEmojis(text) {
 
             // If this is the last emoji in the message and it's the end of the message so far,
             // add a space after it so the user can keep typing easily.
-            if (i === emojiData.length - 1 && text.endsWith(emojiData[i])) {
+            if (addSpace && i === emojiData.length - 1 && text.endsWith(emojiData[i])) {
                 emojiReplacement += ' ';
             }
             newText = newText.replace(emojiData[i], emojiReplacement);
diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js
index 37e5602ca..d49b2464f 100644
--- a/src/pages/home/report/ReportActionCompose.js
+++ b/src/pages/home/report/ReportActionCompose.js
@@ -378,7 +378,7 @@ class ReportActionCompose extends React.Component {
      * @param {Boolean} shouldDebounceSaveComment
      */
     updateComment(comment, shouldDebounceSaveComment) {
-        const newComment = EmojiUtils.replaceEmojis(comment);
+        const newComment = EmojiUtils.replaceEmojis(comment, this.props.isSmallScreenWidth);
         this.setState((prevState) => {
             const newState = {
                 isCommentEmpty: !!newComment.match(/^(\s|`)*$/),
diff --git a/src/pages/home/report/ReportActionItemMessageEdit.js b/src/pages/home/report/ReportActionItemMessageEdit.js
index 2f7fbc29d..5f772d84d 100644
--- a/src/pages/home/report/ReportActionItemMessageEdit.js
+++ b/src/pages/home/report/ReportActionItemMessageEdit.js
@@ -101,7 +101,7 @@ class ReportActionItemMessageEdit extends React.Component {
      * @param {String} draft
      */
     updateDraft(draft) {
-        const newDraft = EmojiUtils.replaceEmojis(draft);
+        const newDraft = EmojiUtils.replaceEmojis(draft, this.props.isSmallScreenWidth);
         this.setState((prevState) => {
             const newState = {draft: newDraft};
             if (draft !== newDraft) {

@s77rt
Copy link
Contributor

s77rt commented Dec 6, 2022

@dylanexpensify Why on mobile only?
Something does not make sense, IMO we should remove the extra space on all platform by removing those lines

App/src/libs/EmojiUtils.js

Lines 202 to 206 in 2e69dac

// If this is the last emoji in the message and it's the end of the message so far,
// add a space after it so the user can keep typing easily.
if (i === emojiData.length - 1 && text.endsWith(emojiData[i])) {
emojiReplacement += ' ';
}

@s77rt
Copy link
Contributor

s77rt commented Dec 6, 2022

Proposal

diff --git a/src/libs/EmojiUtils.js b/src/libs/EmojiUtils.js
index 617c624b2c..2e96216176 100644
--- a/src/libs/EmojiUtils.js
+++ b/src/libs/EmojiUtils.js
@@ -198,12 +198,6 @@ function replaceEmojis(text) {
         const checkEmoji = emojisTrie.search(emojiData[i].slice(1, -1));
         if (checkEmoji && checkEmoji.metaData.code) {
             let emojiReplacement = checkEmoji.metaData.code;
-
-            // If this is the last emoji in the message and it's the end of the message so far,
-            // add a space after it so the user can keep typing easily.
-            if (i === emojiData.length - 1 && text.endsWith(emojiData[i])) {
-                emojiReplacement += ' ';
-            }
             newText = newText.replace(emojiData[i], emojiReplacement);
         }
     }
diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js
index 9eb52bbe28..751dab6445 100644
--- a/src/pages/home/report/ReportActionCompose.js
+++ b/src/pages/home/report/ReportActionCompose.js
@@ -323,13 +323,12 @@ class ReportActionCompose extends React.Component {
      * @param {String} emoji
      */
     addEmojiToTextBox(emoji) {
-        const emojiWithSpace = `${emoji} `;
         const newComment = this.comment.slice(0, this.state.selection.start)
-            + emojiWithSpace + this.comment.slice(this.state.selection.end, this.comment.length);
+            + emoji + this.comment.slice(this.state.selection.end, this.comment.length);
         this.setState(prevState => ({
             selection: {
-                start: prevState.selection.start + emojiWithSpace.length,
-                end: prevState.selection.start + emojiWithSpace.length,
+                start: prevState.selection.start + emoji.length,
+                end: prevState.selection.start + emoji.length,
             },
         }));
         this.updateComment(newComment);
diff --git a/src/pages/home/report/ReportActionItemMessageEdit.js b/src/pages/home/report/ReportActionItemMessageEdit.js
index 2f7fbc29db..960d4a4c9b 100644
--- a/src/pages/home/report/ReportActionItemMessageEdit.js
+++ b/src/pages/home/report/ReportActionItemMessageEdit.js
@@ -177,13 +177,12 @@ class ReportActionItemMessageEdit extends React.Component {
      * @param {String} emoji
      */
     addEmojiToTextBox(emoji) {
-        const emojiWithSpace = `${emoji} `;
         const newComment = this.state.draft.slice(0, this.state.selection.start)
-            + emojiWithSpace + this.state.draft.slice(this.state.selection.end, this.state.draft.length);
+            + emoji + this.state.draft.slice(this.state.selection.end, this.state.draft.length);
         this.setState(prevState => ({
             selection: {
-                start: prevState.selection.start + emojiWithSpace.length,
-                end: prevState.selection.start + emojiWithSpace.length,
+                start: prevState.selection.start + emoji.length,
+                end: prevState.selection.start + emoji.length,
             },
         }));
         this.updateDraft(newComment);

Details

I removed the extra space since it's unwanted and because as a user I would not except to get any extra spaces. Using my keyboard emoji picker does not add spaces, why would the app's emoji picker add spaces?
IMO It's better to remove the extra spaces to keep a consists behaviour and meet user expectations

@dylanexpensify
Copy link
Contributor

to clarify, adding the space for mobile, but not desktop/web is an internal design decision we made @s77rt

@s77rt
Copy link
Contributor

s77rt commented Dec 6, 2022

@dylanexpensify I understand, in this case maybe you should reconsider that decision as I can't see any benefit from adding space after an emoji, if anything it's an unexpected behaviour from user perspective

@dylanexpensify
Copy link
Contributor

Hi @s77rt appreciate your concern, but we're going to move forward with the decision as it is.

@alexpensify
Copy link
Contributor

@youssef-lr - Can you confirm if we should add the External label here to create the job? Thanks!

@youssef-lr
Copy link
Contributor

@dylanexpensify @alexpensify I'll grab this.

@youssef-lr youssef-lr added Weekly KSv2 and removed Daily KSv2 labels Dec 8, 2022
@alexpensify alexpensify added the Internal Requires API changes or must be handled by Expensify staff label Dec 8, 2022
@alexpensify
Copy link
Contributor

Thanks, @youssef-lr! Keep us posted if you need me to test when the fix is ready.

@alexpensify
Copy link
Contributor

@youssef-lr - I'm checking in to see how things are going here.

@alexpensify
Copy link
Contributor

No update yet, I'm going OOO until January 3 and will catch up then to identify if there is any movement here.

@JmillsExpensify
Copy link

For anyone on this thread, this was the Slack thread where we landed on this behavior. Please participate there if you disagree where we landed. This is also largely consistent with how Slack handles it.

@JmillsExpensify
Copy link

In other news, given that this bug will hit the 30 day mark by next week, I'm going to take this over from @alexpensify so we can keep it moving this week and get ahead of this passing that mark. cc @youssef-lr

@JmillsExpensify
Copy link

@youssef-lr I saw you weren't feeling well, and I believe that you're headed OOO soon. Will you be able to circle back on this one earlier next week? I'm mindful of staying ahead of the 30 day mark on this one. I'm happy to help find a volunteer if you're not around.

@JmillsExpensify
Copy link

Huh, it looks like this issue was never updated automatically and the regression period has already past. Let's get this one squared away. Here's how I see this one shaking out.

  • Issue reporter: N/A
  • Contributor: @Puneet-here $1,500 (includes 50% bonus for merging PR quickly)
  • Contributor: @allroundexperts $1,000 (for sharing an idea we ended up using)
  • Contributor+: N/A

@JmillsExpensify JmillsExpensify added Bug Something is broken. Auto assigns a BugZero manager. and removed Bug Something is broken. Auto assigns a BugZero manager. labels Jan 11, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jan 11, 2023

Current assignee @JmillsExpensify is eligible for the Bug assigner, not assigning anyone new.

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jan 11, 2023
@JmillsExpensify
Copy link

Well that didn't work. I'll just create the Upwork job manually. Here it is: https://www.upwork.com/jobs/~01da97f6e1c8796152. Can both of you apply so we can get this paid out tomorrow?

@JmillsExpensify JmillsExpensify changed the title Web/Desktop - Emoji Picker - Space is added after the emoji in compose box [HOLD for payment 2023-01-11] Web/Desktop - Emoji Picker - Space is added after the emoji in compose box Jan 11, 2023
@allroundexperts
Copy link
Contributor

@JmillsExpensify Applied.

@Puneet-here
Copy link
Contributor

Applied, thanks! @JmillsExpensify

@ghost
Copy link

ghost commented Jan 11, 2023

Hello. Thanks for your job posting.

I am a full stack developer who has much experience with web development related emoji.

Please take a look at https://nolanlawson.github.io/emoji-picker-element. I think this project matches with your project very well.

I am ready your job. Hope my experience will be helpful for your project.
Please let me know if you have any questions.

Look forward to discussing more detail about this opportunity.
Thanks for your time and consideration.
(My skype id is live:.cid.a522c4881a36622d)

@JmillsExpensify
Copy link

@allroundexperts @Puneet-here I've extended offers to both of you.

@JmillsExpensify
Copy link

Also for clarity, this was technically a new feature in the name of consistency, so no regressions.

@allroundexperts
Copy link
Contributor

allroundexperts commented Jan 11, 2023 via email

@ghost
Copy link

ghost commented Jan 11, 2023

So I want to know your skype id or mail address. Can you send me them to shinydev1108@gmail.com?

@JmillsExpensify
Copy link

Just waiting on @Puneet-here at this point and then I'll close out the issue.

@Puneet-here
Copy link
Contributor

Sorry for the delay. Accepted now!

@JmillsExpensify JmillsExpensify removed the Bug Something is broken. Auto assigns a BugZero manager. label Jan 12, 2023
@JmillsExpensify
Copy link

Thanks @Puneet-here! You're all set now.

@thesahindia
Copy link
Member

Hey @JmillsExpensify, sorry for the late comment but C+ compensation is due. (Reviewed PR)

@JmillsExpensify
Copy link

Oh, thanks! We need a better process here, probably something you should bring up in C+ in Slack. One idea would be that C+ is responsible for commenting in the issue linked to the PR to ensure that they get assigned and paid. In any case, let's improve our process here, as I notice this keeps happening.

@JmillsExpensify
Copy link

In any case, I invited you to the job as it's still open. Can you please accept? Appreciated!

@thesahindia
Copy link
Member

Applied, thanks @JmillsExpensify

@JmillsExpensify
Copy link

Offer sent.

@JmillsExpensify
Copy link

@thesahindia Before I issue payment, I wanted to clarify the payment. You were assigned as C+ to review this PR, though you didn't review any proposals in this issue. As a result, I think the most fair is to treat this like any other issue where you're just assigned to review a PR. That's $1,000. Does that make sense and do you agree?

@thesahindia
Copy link
Member

Yeah, it makes sense to me.

@JmillsExpensify
Copy link

JmillsExpensify commented Jan 18, 2023

Great thank you! You should be all set now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Daily KSv2 Engineering Reviewing Has a PR in review
Projects
None yet
Development

No branches or pull requests

9 participants