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-11-09] [$500] Chat - Focus on edit even when reaction emoji picker is opened #30119

Closed
2 of 6 tasks
kbecciv opened this issue Oct 21, 2023 · 25 comments
Closed
2 of 6 tasks
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@kbecciv
Copy link

kbecciv commented Oct 21, 2023

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


Version Number: 1.3.88.3
Reproducible in staging?: y
Reproducible in production?: y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @dhanashree-sawant
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1697815510057299

Action Performed:

  1. Open the app
  2. Open any report
  3. Send few messages
  4. React on one message
  5. Edit another message
  6. Click on Emoji in edit
  7. While emoji picker is open, click on Add reaction besides reacted message on step 4
  8. Observe that even though reaction emoji picker is open, app displays focus on edit message

Expected Result:

App should focus on emoji picker search when any emoji picker is opened

Actual Result:

App displays focus on edit message even when reaction emoji picker is opened

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
windows.chrome.focus.on.edit.emoji.picker.mp4
mac.chrome.focus.on.edit.with.emoji.picker.open.mov
Recording.5102.mp4
MacOS: Desktop
mac.desktop.focus.on.edit.with.emoji.picker.open.mov

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~016e9799a4fab4eacb
  • Upwork Job ID: 1715738367180136448
  • Last Price Increase: 2023-10-21
Issue OwnerCurrent Issue Owner: @twisterdotcom
@kbecciv kbecciv added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 21, 2023
@ahmedGaber93
Copy link
Contributor

Proposal

Please re-state the problem that we are trying to solve in this issue.

Open emojiPicker while another emojiPicker is open the edit composer is focus rather than emojiPicker search input

What is the root cause of that problem?

We have two conflicts behavior at the same time when react emojiPicker open while composer emojiPicker is visible.

  1. when composer emojiPicker hide composer input will focus.
  2. when react emojiPicker open emoji search input will focus.
    Regardless who called first, focus two input at the same time is a bug.

What changes do you think we should make in order to solve the problem?

we should stop focus composer emojiPicker if the react emojiPicker will show.

onModalHide={() => {
setIsFocused(true);
focus(true);
}}

onModalHide={() => {
    InteractionManager.runAfterInteractions(() =>  {
        // check if any emojiPicker is open before focus the input
        if (!EmojiPickerAction.isEmojiPickerVisible()) {
            setIsFocused(true);
            focus(true);
        }
    })
}}

What alternative solutions did you explore? (Optional)

N/A

@melvin-bot melvin-bot bot changed the title Chat - Focus on edit even when reaction emoji picker is opened [$500] Chat - Focus on edit even when reaction emoji picker is opened Oct 21, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 21, 2023

Job added to Upwork: https://www.upwork.com/jobs/~016e9799a4fab4eacb

@melvin-bot
Copy link

melvin-bot bot commented Oct 21, 2023

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 21, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 21, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@melvin-bot
Copy link

melvin-bot bot commented Oct 21, 2023

Triggered auto assignment to Contributor-plus team member for initial proposal review - @cubuspl42 (External)

@s-alves10
Copy link
Contributor

Proposal

Please re-state the problem that we are trying to solve in this issue.

Edit composer gets focused when open EmojiPicker using emoji bubble button while EmojiPicker is opened in edit composer

What is the root cause of that problem?

When open EmojiPicker using emoji bubble button while EmojiPicker is opened in edit composer, focus(true) is called onModalHide. And EmojiPicker is opened again and focusEmojiSearchInput is called to set focus to the search input.

The problem is in focus(true). input.focus() is called in InteractionManager.runAfterInteractions callback as you can see in focusWithDelay

InteractionManager.runAfterInteractions(() => {
if (!textInput) {
return;
}
if (!shouldDelay) {
textInput.focus();
return;
}
ComposerFocusManager.isReadyToFocus().then(() => {
if (!textInput) {
return;
}
textInput.focus();
});
});

So the focus() function of edit composer is called after the focus() of search input in EmojiPicker

This is the root cause

What changes do you think we should make in order to solve the problem?

This issue happens for the main composer as well. We need to fix both
There are 2 options:

  1. Don't set focus on the composer when other emoji picker is opened
  2. Call the focus() of search input in InteractionManager.runAfterInteractions callback

With the second solution, the search input would flicker because it gets blurred and gets focused again. So I prefer the first option.

In order to fix both issues, we can prevent focusing of composer if emoji picker is visible in focusWithDelay
Update the below code

if (!textInput) {

to

            if (!textInput || EmojiPickerAction.isEmojiPickerVisible()) {

focusWithDelay function is used only for composer and this works as expected without any side effect

Result
30119.mp4

What alternative solutions did you explore? (Optional)

@iiredalert
Copy link

iiredalert commented Oct 22, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

The emojipicker text field is not in focus when opening the emoji picker from the "Add Reaction" button after the emoji picker was already open from the compose's "Emoji" button.

What is the root cause of that problem?

We are using the onModalHide callback to focus on the compoer's textinput. In this case onModalHide is happening because we are clicking on another button.

What changes do you think we should make in order to solve the problem?

We should only focus on the composer text input if the emoji picker dialog is closed by pressing the "Emoji" button.

Add a specific callback for that in EmojiPickerButton.js:

                onPress={() => {
                    if (!EmojiPickerAction.emojiPickerRef.current.isEmojiPickerVisible) {
                        EmojiPickerAction.showEmojiPicker(props.onModalHide, props.onEmojiSelected, emojiPopoverAnchor.current, undefined, () => {}, props.emojiPickerID);
                    } else {
                        EmojiPickerAction.emojiPickerRef.current.hideEmojiPicker();
                        props.onModalHideDueToPress();
                    }
                }}

Then use that call back to focus on the composer text input in ReportActionItemMessageEdit.js:

                            onModalHideDueToPress={() => {
                                setIsFocused(true);
                                focus(true);
                            }}

We will also need to update the onEmojiSelected callback to focus on the composer text field since it would no longer happen due to the modal dismissal when an emoji is selected.;

ReportActionCompose.js also has this problem if you click somewhere else on the screen (i.e. another textfield) it will force the focus on the ReportActionCompose's textfield

What alternative solutions did you explore? (Optional)

@melvin-bot
Copy link

melvin-bot bot commented Oct 22, 2023

📣 @iiredalert! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@iiredalert
Copy link

Contributor details
Your Expensify account email: iiredalert@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~014796bffcf5c1a24f

@melvin-bot
Copy link

melvin-bot bot commented Oct 22, 2023

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@melvin-bot melvin-bot bot added the Overdue label Oct 24, 2023
@twisterdotcom
Copy link
Contributor

@cubuspl42 just waiting for your take on these proposals please

@melvin-bot melvin-bot bot removed the Overdue label Oct 24, 2023
@cubuspl42
Copy link
Contributor

@s-alves10 I like the fact that you noticed that this affects both edit and main composer.

I'm wondering if the function focusWithDelay has a clear contract, and if we're not making its contract even less clear. Its comment docs states...

Create a function that focuses a text input.

...while the implementation is aware of the composer (it refers to ComposerFocusManager). After our change, it will be also aware of the global emoji picker.

Do you have any thoughts on that? An open option is just updating the comment so it better reflects what this function does. Figuring it out will provoke us to investigate its usages and actual contract.

@s-alves10
Copy link
Contributor

s-alves10 commented Oct 25, 2023

@cubuspl42

Yeah. We use this function only for the composer. And it's related to the composer focus manager.
I think we need to update the comment and function name accordingly

@ahmedGaber93
Copy link
Contributor

ahmedGaber93 commented Oct 25, 2023

@cubuspl42 What do you think of my proposal? It come first and we can do the same for the main composer

@cubuspl42
Copy link
Contributor

@ahmedGaber93 Selecting a proposal based on the order of filing is a last resort. The first and most important property of a proposal should be its overall quality.

@cubuspl42
Copy link
Contributor

While all the proposals provided a solution that would potentially work, I prefer the proposal by @s-alves10 for the following reasons:

  • the focusWithDelay function, with a potential change of the comment doc, seems like the right place for adding this logic, as it's already composer-aware
  • a relatively clean structure of the proposal
  • the fact that it was ensured that the solution works both on the main and the edit composer

C+ reviewed 🎀 👀 🎀

@melvin-bot
Copy link

melvin-bot bot commented Oct 26, 2023

Triggered auto assignment to @flodnv, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 26, 2023
@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Oct 27, 2023
@s-alves10
Copy link
Contributor

@cubuspl42
PR is ready for review #30483

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Nov 2, 2023
@melvin-bot melvin-bot bot changed the title [$500] Chat - Focus on edit even when reaction emoji picker is opened [HOLD for payment 2023-11-09] [$500] Chat - Focus on edit even when reaction emoji picker is opened Nov 2, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Nov 2, 2023
Copy link

melvin-bot bot commented Nov 2, 2023

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented Nov 2, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.94-2 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-11-09. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

For reference, here are some details about the assignees on this issue:

This comment was marked as outdated.

@cubuspl42
Copy link
Contributor

  • The PR that introduced the bug has been identified. Link to the PR:
  • The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
    • No need for additional discussion
  • Determine if we should create a regression test for this bug.
    • Up to the QA team
  • If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
    • Open ND and log in using any account.
    • Navigate to any chat.
    • Send message A.
    • Send message B.
    • React to message A with any emoji.
    • Switch message B to edit mode.
    • Open EmojiPicker by tapping the emoji button in the message B edit composer.
    • Open the EmojiPicker again by tapping the emoji bubble button in message A.
    • Verify that the focus is on EmojiPicker.
    • Open EmojiPicker by tapping the emoji button in the main composer.
    • Reopen EmojiPicker by tapping the emoji bubble button in message A.
    • Confirm that the focus remains on EmojiPicker.

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Nov 8, 2023
@twisterdotcom
Copy link
Contributor

Payment summary:

@dhanashree-sawant
Copy link

Thanks @twisterdotcom, I have accepted the offer.

@melvin-bot melvin-bot bot added the Overdue label Nov 12, 2023
@twisterdotcom
Copy link
Contributor

All paid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

8 participants