Skip to content

[HOLD for payment 2023-10-16] [$500] Dev: Web - Room name field does not automatically focus when returning from the chat option #27607

Closed

Description

@kbecciv

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. Navigate to the "Send message" feature.
  2. Click on Room.
  3. Then Click on the "Chat" option.
  4. Return back to the room.
  5. Observe that the room name field does not auto-focus.

Expected Result:

Upon returning from the chat option, the room name field should automatically receive focus

Actual Result:

The room name field does not auto-focus when returning from the chat option

Workaround:

Unknown

Platforms:

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

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: Dev 1.3.70.5
Reproducible in staging?: n
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
Notes/Photos/Videos: Any additional supporting documentation

screen-recording-2023-09-15-at-101848-pm_pYqHkLAF.mp4

Expensify/Expensify Issue URL:
Issue reported by: @ayazhussain79
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1694798666830459

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0183b28b14d01b5fa6
  • Upwork Job ID: 1703147323818520576
  • Last Price Increase: 2023-09-23
  • Automatic offers:
    • abdulrahuman5196 | Reviewer | 26984474
    • akinwale | Contributor | 26984475

Activity

  1. added
    External
    on Sep 16, 2023
  2. changed the title [-]Dev: Web - Room name field does not automatically focus when returning from the chat option[/-] [+][$500] Dev: Web - Room name field does not automatically focus when returning from the chat option[/+] on Sep 16, 2023
  3. melvin-bot commented on Sep 16, 2023

    @melvin-bot
  4. added
    Help Wanted
    on Sep 16, 2023
  5. melvin-bot commented on Sep 16, 2023

    @melvin-bot

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

  6. melvin-bot commented on Sep 16, 2023

    @melvin-bot

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

  7. akinwale commented on Sep 16, 2023

    @akinwale
    Contributor

    Proposal

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

    The room name input field does not automatically gain focus when returning from the chat option.

    What is the root cause of that problem?

    The autoFocus combined with shouldDelayFocus props set for RoomNameInput do not work properly in conjunction with the navigation focus isFocused property with the tab navigator. autoFocus only works when the component is first mounted. Switching between the tabs in the OnyxTabNavigator does not remount the WorkspaceNewRoomPage, therefore the room name input does not regain focus after switching back to the Room tab.

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

    We are now using a new approach to autofocus text inputs upon launching a screen according to https://expensify.slack.com/archives/C01GTK53T8Q/p1694660990479979

    The following changes need to be made in WorkspaceNewRoomPage.

    1. Add a ref for the RoomNameInput component.
    const roomNameInputRef = useRef(null);
    
    1. Add the timeout ref and the useFocusEffect hook.
    const focusTimeoutRef = useRef(null);
    useFocusEffect(useCallback(() => {
        focusTimeoutRef.current = setTimeout(() => roomNameInputRef.current && roomNameInputRef.current.focus(), CONST.ANIMATED_TRANSITION);
        return () => {
            if (!focusTimeoutRef.current) {
                return;
            }
            clearTimeout(focusTimeoutRef.current);
        };
    }, []));
    
    1. Add the ref prop for RoomNameInput.
    <RoomNameInput
        ref={(el) => roomNameInputRef.current = el}
        inputID="roomName"
        isFocused={props.isFocused}
        shouldDelayFocus
        autoFocus
    />
    

    What alternative solutions did you explore? (Optional)

    None.

  8. c3024 commented on Sep 17, 2023

    @c3024
    Contributor

    Proposal

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

    Room name input is not focused when switching tabs and returning

    What is the root cause of that problem?

    Existing RoomNameInput has focus only on mount and switching tabs does not remount the component.

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

    We are reusing this code for auto focusing input
    Since this will likely be reused at several places we might extract to a custom hook useDelayedFocus

    import { useCallback, useRef } from 'react';
    import { useFocusEffect } from '@react-navigation/native';
    import CONST from '../CONST';
    
    export function useDelayedFocus(textInputRef, delay = CONST.ANIMATED_TRANSITION) {
      const focusTimeoutRef = useRef(null);
    
      useFocusEffect(
        useCallback(() => {
          focusTimeoutRef.current = setTimeout(() => {
            if (textInputRef.current) {
              textInputRef.current.focus();
            }
          }, delay);
          return () => {
            if (focusTimeoutRef.current) {
              clearTimeout(focusTimeoutRef.current);
            }
          };
        }, [delay, textInputRef])
      );
    }

    and use it in WorkspaceNewRoomPage

    const roomNameInputRef = useRef(null);
    useDelayedFocus(roomNameInputRef)

    and add the ref to RoomNameInput

    ref={(ref) => (roomNameInputRef.current = ref)}

    and remove shouldDelayFocus here.

    What alternative solutions did you explore? (Optional)

  9. MitchExpensify commented on Sep 18, 2023

    @MitchExpensify
    Contributor

    This is on dev and not reproducible on staging (v1.3.71-5) or prod (v1.3.70-8). I think we should close this until its reproducible on either staging or prod

  10. c3024 commented on Sep 22, 2023

    @c3024
    Contributor

    This is now on staging v1.3.72-9. @MitchExpensify

  11. 32 remaining items

  12. melvin-bot commented on Oct 9, 2023

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.79-5 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-10-16. 🎊

    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:

    As a reminder, here are the bonuses/penalties that should be applied for any External issue:

    • Merged PR within 3 business days of assignment - 50% bonus
    • Merged PR more than 9 business days after assignment - 50% penalty
  13. added
    Daily
    and removed
    Weekly
    Daily
    on Oct 16, 2023
  14. abdulrahuman5196 commented on Oct 16, 2023

    @abdulrahuman5196
    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:

    Not a regression. Seems to be misses from latest UI rewamps.

    Determine if we should create a regression test for this bug.
    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.

    1. Open the global create menu and select Send message
    2. Click on the Room tab if it is not the active tab.
    3. Verify that the room name input field gains focus.
    4. Click on the Chat tab.
    5. Click on the Room tab.
    6. Verify that the room name input field regains focus.
    7. Repeat steps 6 through 8 a few more times.
  15. akinwale commented on Oct 18, 2023

    @akinwale
    Contributor

    @MitchExpensify Just checking in here for payment. Thanks.

  16. MitchExpensify commented on Oct 18, 2023

    @MitchExpensify
    Contributor

    Payment summary:

    All Upwork:

  17. MitchExpensify commented on Oct 18, 2023

    @MitchExpensify
    Contributor

    Paid and contract ended, thanks for the bump!

    Just waiting on test rail updates (On me)

    And @ayazhussain79 to accept Upwork offer

  18. ayazhussain79 commented on Oct 19, 2023

    @ayazhussain79
    Contributor

    @MitchExpensify offer accepted, Thank you

  19. MitchExpensify commented on Oct 20, 2023

    @MitchExpensify
    Contributor

    Mind sharing the offer/contract with me @ayazhussain79, I cannot find it in Upwork 😅 (Their search is terrible)

  20. MitchExpensify commented on Oct 20, 2023

    @MitchExpensify
    Contributor
  21. ayazhussain79 commented on Oct 20, 2023

    @ayazhussain79
    Contributor

    @MitchExpensify I think there is no option to copy contract URL so sent you message on upwork.

  22. MitchExpensify commented on Oct 22, 2023

    @MitchExpensify
    Contributor

    Paid! Thanks @ayazhussain79

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

Metadata

Metadata

Labels

Awaiting PaymentDailyExternal

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions