Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.45k stars 2.8k forks source link

[$1000] Chat - Composer Not focused when clicking on composer box #25892

Open lanitochka17 opened 1 year ago

lanitochka17 commented 1 year ago

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. Go to any chat
  2. Send a message
  3. Click on Edit from the reaction menu
  4. Click on the emoji menu in the edit composer
  5. Now without closing the emoji box click on the main composer

Expected Result:

Clicking on the main composer box focuses the composer

Actual Result:

Clicking on the main composer box focuses on the main composer for a second and then focuses on the edit Composer

Workaround:

Unknown

Platforms:

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

Version Number: 1.3.57-1

Reproducible in staging?: Yes

Reproducible in production?: Yes

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

Notes/Photos/Videos: Any additional supporting documentation

https://github.com/Expensify/App/assets/78819774/4769bf78-138c-49eb-b734-1a87ff23a738

https://github.com/Expensify/App/assets/78819774/1fb3cb4e-2436-41d7-9d85-2a2fa1a3b4e2

Expensify/Expensify Issue URL:

Issue reported by: @daveSeife

Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1692048812228079

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0161d746e7dbb99cde
  • Upwork Job ID: 1695206421110677504
  • Last Price Increase: 2023-09-15
  • Automatic offers:
    • tienifr | Contributor | 26745373
    • daveSeife | Reporter | 26745374
melvin-bot[bot] commented 1 year ago

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

melvin-bot[bot] commented 1 year ago

Bug0 Triage Checklist (Main S/O)

hoangzinh commented 1 year ago

Proposal

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

Composer Not focused when clicking on composer box

What is the root cause of that problem?

In the ReportActionItemMessageEdit component, we have a callback when Emoji picker modal is hidden, it will focus back to the editing report message https://github.com/Expensify/App/blob/34d4e54055c3fee2a04e2fc11af82fe454197ff9/src/pages/home/report/ReportActionItemMessageEdit.js#L379-L382

So even if we click focus on the main composer, by above callback, it will focus back to the editing report message

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

In the above onModalHide callback, we need to check if the main composer is focusing, we will early exit and won't focus back to the editing report message

Result:

https://github.com/Expensify/App/assets/9639873/f6070368-fc5f-484f-93b3-4327050d5076

melvin-bot[bot] commented 1 year ago

Job added to Upwork: https://www.upwork.com/jobs/~0161d746e7dbb99cde

melvin-bot[bot] commented 1 year ago

Current assignee @MitchExpensify is eligible for the External assigner, not assigning anyone new.

melvin-bot[bot] commented 1 year ago

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

tienifr commented 1 year ago

Proposal

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

Composer Not focused when clicking on composer box

What is the root cause of that problem?

When Emoji picker modal is closed, it will focus back to the edit composer regardless of any user interaction:

https://github.com/Expensify/App/blob/253db3263d0159724399ccde717791c2473045f2/src/pages/home/report/ReportActionItemMessageEdit.js#L379-L382

So even if we click focus on the main compose, it will always focus back to the edit compose.

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

Update: As previously discussed here, we should move all ReportActionComposeFocusManager-related codes out of the standalone Composer.

Since PR https://github.com/Expensify/App/pull/24481, we have a way to re-focus on the "right" compose:

  1. So there's no need for manual check for currently focused compose because ReportActionFocusManager will handle it. In ReportActionItemMessageEdit:
    onModalHide={() => {
    ReportActionComposeFocusManager.focus();
    }}
  2. Add the onComposerFocus callback:
    onFocus={() => {
    ...
    ReportActionComposeFocusManager.onComposerFocus(() => {
        if (!willBlurTextInputOnTapOutside) {
            return;
        }
        focus(true);
    });
    }}
  3. And unsubscribe it using ReportActionComposeFocusManager.clear() on unmount
  4. Remove all ReportActionComposeFocusManager-related codes out of the standalone Composer
parasharrajat commented 1 year ago

OK. Thanks for the proposals. My intuition is asking to hold this issue as we have done for https://github.com/Expensify/App/issues/23403. Even though solutions might not overlap they seem quite related.

Also, I was checking on https://github.com/Expensify/App/pull/24481 and the implementation doesn't seem very scalable. This is out of the scope of this issue but we can pursue improving that as well.

rojiphil commented 1 year ago

Isn’t this an expected behaviour? When the EmojiPicker is displayed, we do not allow interactions with any other element in Report Screen until it is dismissed. A tap on anywhere else other than the EmojiPicker will hide and bring the focus back on the currently edited message input.

parasharrajat commented 1 year ago

That was the behavior a few months back but it seems that it is recently changed. I am not sure where.

MitchExpensify commented 1 year ago

@parasharrajat do you still think this is the best course of action here?

My intuition is asking to hold this issue as we have done for https://github.com/Expensify/App/issues/23403.

parasharrajat commented 1 year ago

The reason behind this is that a single PR caused these issues and C+ can pick a more complete solution in https://github.com/Expensify/App/issues/23403 to fix the issue completely. I am monitoring the review of the other issue. If it seems that we are not solving this issue there, I will continue here.

Does that sound good? or do you want me to continue on this issue?

melvin-bot[bot] commented 1 year ago

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

MitchExpensify commented 1 year ago

I am monitoring the review of the other issue. If it seems that we are not solving this issue there, I will continue here.

This sounds great to me! Thank you

tienifr commented 1 year ago

@parasharrajat As previously discussed here, I updated my proposal to refactor the ReportActionComposeFocusManager codes. I've run through all test cases in related PRs: https://github.com/Expensify/App/pull/23258, https://github.com/Expensify/App/pull/24481 and https://github.com/Expensify/App/pull/23994 and it worked fine.

MitchExpensify commented 1 year ago

Sounds like @tienifr's proposal is updated and ready for you @parasharrajat

melvin-bot[bot] commented 1 year ago

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

MitchExpensify commented 1 year ago

Friendly bump on an update here @parasharrajat 👍

MitchExpensify commented 1 year ago

Bump @parasharrajat 🙇

parasharrajat commented 1 year ago

Checking the current state as https://github.com/Expensify/App/issues/23403 is completed.

parasharrajat commented 1 year ago

I couldn't reproduce this issue. cc; @MitchExpensify Can you try?

tienifr commented 1 year ago

I can still reproduce it. Remember to keep the emoji picker open.

https://github.com/Expensify/App/assets/113963320/6c289de6-eff2-4255-9ee2-1206b5886b75

melvin-bot[bot] commented 1 year ago

@parasharrajat @MitchExpensify this issue is now 3 weeks old. There is one more week left before this issue breaks WAQ and will need to go internal. What needs to happen to get a PR in review this week? Please create a thread in #expensify-open-source to discuss. Thanks!

MitchExpensify commented 1 year ago

I can still reproduce @parasharrajat

melvin-bot[bot] commented 1 year ago

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

parasharrajat commented 1 year ago

Ok, I will recheck it in sometime.

tienifr commented 1 year ago

My proposal can fix this issue as well: https://github.com/Expensify/App/issues/27612.

ilkeruyanik commented 1 year ago

Proposal

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

When emoji picker is closed, text input is focused even if it should not focus.

What is the root cause of that problem?

EmojiPickerButton Component's onModalHide property sets focus without any condition in ReportActionItemMessageEdit Component, when emoji picker is closed.

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

  1. Instead of setting focus directly, we should use ReportActionComposeFocusManager. https://github.com/Expensify/App/blob/c77814fd5e643cba78e8c8294370d78f633a59c5/src/pages/home/report/ReportActionItemMessageEdit.js#L411-L414

These lines will be changed with

onModalHide={() => {
    InteractionManager.runAfterInteractions(() => {
        if (EmojiPickerAction.isEmojiPickerVisible()) {
            return;
        }
        ReportActionComposeFocusManager.focus();
    });
}}

We need to use InteractionManager, because user may open emoji picker while already open for another edit composer.

  1. New property 'onPress' will be added to EmojiPickerButton component. We will send a function for run on onPress. In this case, we will use it for set ReportActionComposeFocusManager.onComposerFocus function. We will need to set ReportActionComposeFocusManager.onComposerFocus because user may close emoji picker without focus on edit composer.

    onPress={() => {
    ReportActionComposeFocusManager.onComposerFocus(() => {
        if (!textInputRef.current) {
            return;
        }
    
        textInputRef.current.focus();
    });
    }}

    Current action is setting ReportActionComposeFocusManager.onComposerFocus on onFocus in Composer Component. https://github.com/Expensify/App/blob/c77814fd5e643cba78e8c8294370d78f633a59c5/src/components/Composer/index.js#L471-L483

Result

https://github.com/Expensify/App/assets/93402058/61304066-809e-4dd2-935d-e4607fd7af60

This approach is fixing this issue as well as fixing #27612.

parasharrajat commented 1 year ago

@tienifr 's proposal looks good to me given that we are already following that pattern.

Apart from that, @tienifr will be doing this refactor https://github.com/Expensify/App/pull/24481#discussion_r1306638535.

:ribbon: :eyes: :ribbon: C+ reviewed

melvin-bot[bot] commented 1 year ago

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

melvin-bot[bot] commented 1 year ago

📣 @parasharrajat Please request via NewDot manual requests for the Reviewer role ($1000)

melvin-bot[bot] commented 1 year ago

📣 @tienifr 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link Upwork job Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻 Keep in mind: Code of Conduct | Contributing 📖

melvin-bot[bot] commented 1 year ago

📣 @daveSeife 🎉 An offer has been automatically sent to your Upwork account for the Reporter role 🎉 Thanks for contributing to the Expensify app!

Offer link Upwork job

tienifr commented 1 year ago

Investigated further and found several possible regressions. I think this would take more time to submit a complete PR.

melvin-bot[bot] commented 1 year ago

@johnmlee101 @parasharrajat @MitchExpensify @tienifr this issue is now 4 weeks old and preventing us from maintaining WAQ, can you:

Thanks!

melvin-bot[bot] commented 1 year ago

Current assignee @parasharrajat is eligible for the Internal assigner, not assigning anyone new.

melvin-bot[bot] commented 1 year ago

@johnmlee101, @parasharrajat, @MitchExpensify, @tienifr Huh... This is 4 days overdue. Who can take care of this?

parasharrajat commented 1 year ago

@tienifr Any update?

johnmlee101 commented 1 year ago

@tienifr do you mind sharing a work-in-progress PR so we can stay up-to-date on progress you're making?

tienifr commented 1 year ago

Some latest changes to the Composer component invalidate my former solution. I'm prioritizing this one.

melvin-bot[bot] commented 1 year ago

@johnmlee101, @parasharrajat, @MitchExpensify, @tienifr Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

MitchExpensify commented 1 year ago

Whats the latest here @tienifr ?

MitchExpensify commented 1 year ago

Bump @tienifr

tienifr commented 1 year ago

Implementation was done. Updating screenshots. Expect to open PR in the next hour. Hope that there's no breaking changes from main.

tienifr commented 1 year ago

PR is ready for review: https://github.com/Expensify/App/pull/28238.

melvin-bot[bot] commented 11 months ago

This issue has not been updated in over 15 days. @johnmlee101, @parasharrajat, @MitchExpensify, @tienifr eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

parasharrajat commented 11 months ago

@tienifr Waiting for your response on the PR.

parasharrajat commented 10 months ago

Still waiting on update @tienifr

cc: @MitchExpensify

tienifr commented 10 months ago

Prioritizing this now.

melvin-bot[bot] commented 8 months ago

@johnmlee101, @parasharrajat, @MitchExpensify, @tienifr, this Monthly task hasn't been acted upon in 6 weeks; closing.

If you disagree, feel encouraged to reopen it -- but pick your least important issue to close instead.