You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[$500] Android - Create room - Inconsistent behavior of cursor after selecting workspace/visibility #31224
BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors
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:
Open the app
Tap the FAB > Start chat > Room
Enter the room name
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?
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
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.
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.
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.
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.,
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. 😄
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
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.
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.
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!
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.
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?
BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors
Activity
[-]Android - Create room - Inconsistent behavior of cursor after selecting workspace/visibility[/-][+][$500] Android - Create room - Inconsistent behavior of cursor after selecting workspace/visibility[/+]melvin-bot commentedon Nov 11, 2023
Job added to Upwork: https://www.upwork.com/jobs/~01fbab8ee06aa1521a
melvin-bot commentedon Nov 11, 2023
Triggered auto assignment to @sakluger (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Nov 11, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)melvin-bot commentedon Nov 11, 2023
Triggered auto assignment to Contributor-plus team member for initial proposal review - @hoangzinh (
External)bernhardoj commentedon Nov 11, 2023
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)
tienifr commentedon Nov 11, 2023
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.
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
willAlertModalBecomeVisibleof the Modal, it will become true right before the modal open, we need to listen to the modal state and dismiss the keyboard if thewillAlertModalBecomeVisiblechanges 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 commonuseDismissKeyboardOnModalOpenhook for reuse.We use
onyxSubscribeto minimize unnecessary component rerendering if the screen is not focused, this is already used elsewhere in the app. 1 alternative is to connect tomodalin Onyx in the component.Then we can use the hook in the
WorkspaceNewRoomPageand any other page that has the issue.What alternative solutions did you explore? (Optional)
We can add
Keyboard.dismissindividually 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
useAutoFocusInputhook. If themodal.isVisiblechanges from true to false, we'll autofocus the input.bernhardoj commentedon Nov 11, 2023
(image taken from #24452 (comment))
AFAICT, it will be applied to all Modal.
They also plan to add
shouldRestoreKeyboardprop to the modal and in this case, we pass it as false. So, it's better to hold this.63 remaining items
ntdiary commentedon Jun 13, 2024
Hi, I think this is one of the situations in the general modal focus case.
Ideally, using these two props within the
ValueSelectorModalshould 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
modalcomponent mounts earlier than the libraryonModalWillShow, 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.,
Here is the final result:
demo.mp4
We could also consider hiding the keyboard earlier in the
onPressevent 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. 😄
hoangzinh commentedon Jun 14, 2024
Thanks for your suggestion @ntdiary. I will try to check it.
[-][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[/+]sakluger commentedon Jun 14, 2024
It sounds like the remaining parts of the hold issue won't solve this, so I've added the help wanted label back.
melvin-bot commentedon Jun 15, 2024
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
hoangzinh commentedon Jun 15, 2024
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.
ntdiary commentedon Jun 17, 2024
@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. :)hoangzinh commentedon Jun 17, 2024
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?
sakluger commentedon Jun 17, 2024
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!
hoangzinh commentedon Jun 17, 2024
Sure @sakluger.
@tienifr @bernhardoj anyone agree with my thoughts here and volunteer to implement it? Thank you.
bernhardoj commentedon Jun 18, 2024
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.
hoangzinh commentedon Jun 18, 2024
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
sakluger commentedon Jun 18, 2024
Thanks @bernhardoj for retesting! Yes, let's close this out.