Skip to content

[$500] Android - Create room - Inconsistent behavior of cursor after selecting workspace/visibility #31224

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!


Version Number: 1.3.98.0
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: Applause - Internal Team
Slack conversation:

Action Performed:

  1. Open the app
  2. Tap the FAB > Start chat > Room
  3. Enter the room name
  4. Select the workspace and/or visibility

Expected Result:

The cursor is not shown, and the keyboard is hidden

Actual Result:

On Android and iOS, the cursor returns to the room name, and the field is highlighted, while on web and mweb, the cursor is not seen, and the keyboard is hidden on mweb. On iOS, the keyboard overlaps the "Create room" button. Also, the keyboard is hidden on Samsung s10+, while it appears on Pixel 6.

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

Bug6271875_1699653421342.Android_pixel6.mp4

View all open jobs on GitHub

Bug6271875_1699653421346.iOS.mp4
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01fbab8ee06aa1521a
  • Upwork Job ID: 1723173111736639488
  • Last Price Increase: 2024-06-15

Activity

  1. added
    External
    Daily
    Bug
    on Nov 11, 2023
  2. changed the title [-]Android - Create room - Inconsistent behavior of cursor after selecting workspace/visibility[/-] [+][$500] Android - Create room - Inconsistent behavior of cursor after selecting workspace/visibility[/+] on Nov 11, 2023
  3. melvin-bot commented on Nov 11, 2023

    @melvin-bot
  4. melvin-bot commented on Nov 11, 2023

    @melvin-bot

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

  5. added
    Help Wanted
    on Nov 11, 2023
  6. melvin-bot commented on Nov 11, 2023

    @melvin-bot

    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
  7. melvin-bot commented on Nov 11, 2023

    @melvin-bot

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

  8. bernhardoj commented on Nov 11, 2023

    @bernhardoj
    Contributor

    The workspace/visibility is a modal, so the focus will be restored once the modal is closed. I think we should hold this for #24452 (comment)

  9. tienifr commented on Nov 11, 2023

    @tienifr
    Contributor

    The workspace/visibility is a modal, so the focus will be restored once the modal is closed. I think we should hold this for #24452 (comment)

    That other issue is related to Composer only, and only there we have the "the focus will be restored once the modal is closed" behavior. Here we should dismiss the keyboard when modal opens like the Expected suggested, because when the user goes to workspace/visibility step, it's most likely they already completes entering the room name and there's no need to refocus on the room name input.

    Proposal

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

    On Android and iOS, the cursor returns to the room name, and the field is highlighted, while on web and mweb, the cursor is not seen, and the keyboard is hidden on mweb. Also, the keyboard is hidden on Samsung s10+, while it appears on Pixel 6.

    On iOS, the keyboard overlaps the "Create room" button.

    This part is out of scope and I believe we already have another ticket to remove that.

    What is the root cause of that problem?

    In iOS and some Android devices, if a modal is opened while a keyboard is open, the keyboard will be dismissed natively but will resurface after the modal is closed. It's native behavior. While for web/mWeb it doesn't have that behavior.

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

    We need to proactively dismiss the keyboard before the modal opens. We can do that by making use of the willAlertModalBecomeVisible of the Modal, it will become true right before the modal open, we need to listen to the modal state and dismiss the keyboard if the willAlertModalBecomeVisible changes from false to true. Also we'll only listen to the modal state if the current screen is focused. We can put the logic in a common useDismissKeyboardOnModalOpen hook for reuse.

    function useDismissKeyboardOnModalOpen() {
        const willAlertModalBecomeVisibleRef = useRef(false);
        const isFocused = useIsFocused();    
    
        useEffect(() => {
            if (!isFocused) {
                return;
            }
            const unsubscribeOnyxModal = onyxSubscribe({
                key: ONYXKEYS.MODAL,
                callback: (modalArg) => {
                    if (_.isNull(modalArg) || typeof modalArg !== 'object') {
                        return;
                    }
    
                    if (!willAlertModalBecomeVisibleRef.current && modalArg.willAlertModalBecomeVisible) {
                        Keyboard.dismiss();
                    }
    
                    willAlertModalBecomeVisibleRef.current = modalArg.willAlertModalBecomeVisible;
                },
            });
    
            return () => unsubscribeOnyxModal && unsubscribeOnyxModal();
        }, [isFocused]);
    }
    

    We use onyxSubscribe to minimize unnecessary component rerendering if the screen is not focused, this is already used elsewhere in the app. 1 alternative is to connect to modal in Onyx in the component.

    Then we can use the hook in the WorkspaceNewRoomPage and any other page that has the issue.

    What alternative solutions did you explore? (Optional)

    We can add Keyboard.dismiss individually on press of the Workspace/visibility, but above is a more global fix.

    If instead we want to autofocus whenever the modal closes, we can implement similarly in the useAutoFocusInput hook. If the modal.isVisible changes from true to false, we'll autofocus the input.

  10. bernhardoj commented on Nov 11, 2023

    @bernhardoj
    Contributor
    image

    (image taken from #24452 (comment))

    That other issue is related to Composer only,

    AFAICT, it will be applied to all Modal.

    and there's no need to refocus on the room name input.

    They also plan to add shouldRestoreKeyboard prop to the modal and in this case, we pass it as false. So, it's better to hold this.

  11. 63 remaining items

  12. ntdiary commented on Jun 13, 2024

    @ntdiary
    Contributor

    Expected Result:

    The cursor is not shown, and the keyboard is hidden

    Hi, I think this is one of the situations in the general modal focus case.
    Ideally, using these two props within the ValueSelectorModal should be sufficient to address this issue.

        onBackdropPress={onBackdropPress}
    +   shouldEnableNewFocusManagement
    +   restoreFocusType="delete"

    However, it's worth noting that there is an issue with react-native-modal.
    In the new Fabric architecture, the native modal component mounts earlier than the library onModalWillShow, causing the iOS system to save the keyboard state and blur the keyboard before our JS layer does.
    We need to make a tweak to proactively hide the keyboard in our app before the iOS system does.
    e.g.,
    image

    Here is the final result:

    demo.mp4

    We could also consider hiding the keyboard earlier in the onPress event to address this specific case. As for other focusing logic, as I described here #24452 (comment), it may be cleaned up later.

    If you all agree with these thoughts, I think we don't need to hold this issue any longer. It would be great if a contributor is willing to raise a PR to fix this issue. I'm happy to share some information and, of course, still remain open to different opinions. 😄

  13. hoangzinh commented on Jun 14, 2024

    @hoangzinh
    Contributor

    Thanks for your suggestion @ntdiary. I will try to check it.

  14. changed the title [-][HOLD #24452][$500] Android - Create room - Inconsistent behavior of cursor after selecting workspace/visibility[/-] [+][$500] Android - Create room - Inconsistent behavior of cursor after selecting workspace/visibility[/+] on Jun 14, 2024
  15. added
    Help Wanted
    on Jun 14, 2024
  16. sakluger commented on Jun 14, 2024

    @sakluger
    Contributor

    It sounds like the remaining parts of the hold issue won't solve this, so I've added the help wanted label back.

  17. melvin-bot commented on Jun 15, 2024

    @melvin-bot

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

  18. hoangzinh commented on Jun 15, 2024

    @hoangzinh
    Contributor

    In the new Fabric architecture, the native modal component mounts earlier than the library onModalWillShow, causing the iOS system to save the keyboard state and blur the keyboard before our JS layer does.

    Hi @ntdiary is there any reported issue in react-native-modal or it's just what you found during phases 1 & 2 in your issue? Thank you.

  19. ntdiary commented on Jun 17, 2024

    @ntdiary
    Contributor

    Hi @ntdiary is there any reported issue in react-native-modal or it's just what you found during phases 1 & 2 in your issue? Thank you.

    @hoangzinh, It's only what I found while testing my PR. As for react-native-modal, it seems it hasn't been updated in two years. :)

  20. hoangzinh commented on Jun 17, 2024

    @hoangzinh
    Contributor

    Screenshot 2024-06-17 at 18 28 50

    Thanks for confirming @ntdiary. I think what @ntdiary suggested here is the best so far. It works well with new focus management. But we might need to conditional it to only trigger on the 1st render.

    What do you guys think?

  21. sakluger commented on Jun 17, 2024

    @sakluger
    Contributor

    I'm not an engineer so I can't really evaluate how good that solution is 🙂. @hoangzinh feel free to C+ approve the proposal so we can get a BE engineer assigned to confirm. Thanks!

  22. hoangzinh commented on Jun 17, 2024

    @hoangzinh
    Contributor

    Sure @sakluger.
    @tienifr @bernhardoj anyone agree with my thoughts here and volunteer to implement it? Thank you.

  23. bernhardoj commented on Jun 18, 2024

    @bernhardoj
    Contributor

    After retesting, I found that the behavior on all platforms now is the same. The room name field is refocused after selecting the workspace visibility because of the focus trap.

  24. hoangzinh commented on Jun 18, 2024

    @hoangzinh
    Contributor

    Thanks for retesting it @bernhardoj. I confirmed that the above behavior is consistent between mWeb and native atm. cc @sakluger should we close this issue?

    Screen.Recording.2024-06-18.at.16.45.43.mov
  25. sakluger commented on Jun 18, 2024

    @sakluger
    Contributor

    Thanks @bernhardoj for retesting! Yes, let's close this out.

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

Metadata

Metadata

Labels

BugDailyExternalHelp Wanted

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions