Skip to content

Chat - Focus lost after choosing emoji from EmojPicker #33984

Closed

Description

@lanitochka17

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.4.22-0
Reproducible in staging?: Y
Reproducible in production?: N
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: Applause - Internal Team
Slack conversation:

Action Performed:

  1. Go to URL https://staging.new.expensify.com/
  2. Login with any account
  3. Open any chat
  4. Open the emoji picker
  5. Choose any emoji

Expected Result:

Focus presents in the composer

Actual Result:

Focus lost in composer

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

Add any screenshot/video evidence

Bug6332575_1704403879275.bandicam_2024-01-04_23-09-06-274.1.mp4

View all open jobs on GitHub

Activity

  1. added
    DeployBlockerCash
    on Jan 4, 2024
  2. github-actions commented on Jan 4, 2024

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  3. melvin-bot commented on Jan 4, 2024

    @melvin-bot

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

  4. lanitochka17 commented on Jan 4, 2024

    @lanitochka17
    Author

    Production:

    Recording.873.mp4
  5. DylanDylann commented on Jan 5, 2024

    @DylanDylann
    Contributor

    Proposal

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

    • Chat - Focus lost after choosing emoji from EmojPicker

    What is the root cause of that problem?

    • It is a regression from
    • We have the logic that do not focus on the input composer if we the isPopoverOpen is true:
      const focus = useCallback(
      (shouldDelay = false) => {
      if (isPopoverOpen) {
      return;
      }
      focusComposerWithDelay(textInputRef.current)(shouldDelay);
      },
      [isPopoverOpen],
      );
    • When we select a emoji, it will call the above focus function but at that time, isPopoverOpen is still true, that leads to the bug.

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

    • First, we need to remove the logic that leads to the bug byt updating the above to:
    const focus = useCallback( 
        (shouldDelay = false) => { 
            focusComposerWithDelay(textInputRef.current)(shouldDelay); 
        }, 
        [], 
    ); 
    
    • Then, create the global variable, named willContextMenuOpen in here to know if the context menu is opening or not.
    • Then, once we open the context menu, set the ComposerFocusManager.willContextMenuOpen = true. Do it by updating:
      onSecondaryInteraction={(e) => {
      showPopover(e);

      to:
                            onSecondaryInteraction={(e) => {
                                showPopover(e);
    +                           ComposerFocusManager.willContextMenuOpen = true
    • Then, prevent the app from focusing on the composer if the willContextMenuOpen is true. Do it by updating:
      if (!textInput || EmojiPickerAction.isEmojiPickerVisible()) {
      return;
      }

      to:
    +      if (!textInput || EmojiPickerAction.isEmojiPickerVisible() || ComposerFocusManager.isContextMenuAction) {
    +          ComposerFocusManager.isContextMenuAction = false
                return;
            }

    What alternative solutions did you explore? (Optional)

    • NA
  6. Pujan92 commented on Jan 6, 2024

    @Pujan92
    Contributor

    Proposal

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

    Composer isn't focus after selecting an emoji

    What is the root cause of that problem?

    On selection of emoji we are hiding the emoji picker but do not execute the close method of the PopoverContext which eventually doesn't update the isOpen value, due to that isPopoverOpen remains true here and it won't focus the composer.

    const focus = useCallback(
    (shouldDelay = false) => {
    if (isPopoverOpen) {
    return;
    }
    focusComposerWithDelay(textInputRef.current)(shouldDelay);
    },
    [isPopoverOpen],
    );

    const selectEmoji = (emoji, emojiObject) => {
    // Prevent fast click / multiple emoji selection;
    // The first click will hide the emoji picker by calling the hideEmojiPicker() function
    if (!isEmojiPickerVisible) {
    return;
    }
    hideEmojiPicker(false);
    if (_.isFunction(onEmojiSelected.current)) {
    onEmojiSelected.current(emoji, emojiObject);
    }
    };

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

    Use Popover context in the EmojiPicker for close method and call it inside selectEmoji function.

    hideEmojiPicker(false);

  7. situchan commented on Jan 6, 2024

    @situchan
    Contributor

    @Pujan92 what's offending PR? #33483 was deployed to production

  8. Pujan92 commented on Jan 6, 2024

    @Pujan92
    Contributor

    @Pujan92 what's offending PR? #33483 was deployed to production

    Offending PR is #33483 only bt currently emoji picker by mistake in other PR is opening as Modal(instead of PopoverWithoutOverlay) so we are not able to reproduce at the moment(bcoz Modal onClose is calling close method).
    I think it will be reproducible in production once this PR hits there.

  9. mvtglobally commented on Jan 7, 2024

    @mvtglobally

    still repro on build 1.4.22-2

    Recording.894.mp4
  10. thienlnam commented on Jan 8, 2024

    @thienlnam
    Contributor

    Situ is handling as C+

  11. situchan commented on Jan 8, 2024

    @situchan
    Contributor

    I agree with #32970 (comment).
    As regression test is already done, revert is safer approach and original issue is not that critical.
    I am concerned applying patch will cause another unexpected regression.
    @thienlnam what do you think?

  12. 6 remaining items

  13. added
    Bug
    on Jan 10, 2024
  14. melvin-bot commented on Jan 10, 2024

    @melvin-bot

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

  15. thienlnam commented on Jan 10, 2024

    @thienlnam
    Contributor

    This blocker was fixed in the revert - adding the bug label so we can get payment issued

  16. sophiepintoraetz commented on Jan 10, 2024

    @sophiepintoraetz
    Contributor

    @thienlnam - can you confirm it's just $500 to @situchan?

  17. thienlnam commented on Jan 10, 2024

    @thienlnam
    Contributor

    Yes that is correct!

  18. DylanDylann commented on Jan 10, 2024

    @DylanDylann
    Contributor

    @thienlnam I proposed the proposal that point out the RCA and solution to revert the PR here, can you help check

  19. thienlnam commented on Jan 10, 2024

    @thienlnam
    Contributor

    It doesn't look like your comment mentioned the PR that caused the regression - also since we're just reverting code here we're going to have the problem resolved in that PR

  20. DylanDylann commented on Jan 10, 2024

    @DylanDylann
    Contributor

    @thienlnam My proposal have 2 sections:

    First, we need to remove the logic that leads to the bug byt updating the above to ...

    This is revert the regression PR

    And the rest is the solution that will fix the issue that the regression PR try to fix

  21. thienlnam commented on Jan 10, 2024

    @thienlnam
    Contributor

    Yeah but I don't see the regression PR linked in your comment anywhere.

    Additionally, in these scenarios where we revert a recent PR we don't issue payment for just pointing out where it was caused. If we had implemented your other solution that would be a different situation, but it sounds like we decided to just go with a revert here due to other reasons as well listed here

  22. DylanDylann commented on Jan 10, 2024

    @DylanDylann
    Contributor

    @thienlnam

    revert here due to other reasons as well listed #32970 (comment)

    In the comment you mentioned, the author mentioned my proposal "More info is explained on the #33984 (comment) there."

    Can you help check

  23. mkhutornyi commented on Jan 10, 2024

    @mkhutornyi

    @DylanDylann as you're not assigned, I don't think you're eligible even if it's not straight revert.
    And this GH was not made external so there's no guarantee of payment even if your solution is used.
    Similar case: #33228 (comment) (I even helped review PR)

  24. sophiepintoraetz commented on Jan 10, 2024

    @sophiepintoraetz
    Contributor

    Hey @DylanDylann - we have plenty of opportunities to jump in if you're looking for monetary compensation but as Jack has said, this is mainly a revert - we have not implemented code. If we implement something, I'd keep an eye out on #32970 (comment).

    @situchan - offer sent!

  25. DylanDylann commented on Jan 10, 2024

    @DylanDylann
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugDailyEngineering

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions