fix: prevent composer keyboard from dismissing on open on small Android screens#7387
fix: prevent composer keyboard from dismissing on open on small Android screens#7387OtavioStasiak wants to merge 3 commits into
Conversation
…creens
useCloseKeyboardWhenOrientationChanges read useSafeAreaFrame to detect
rotation, but under adjustResize + edge-to-edge that frame shrinks when the
soft keyboard opens. On small screens (e.g. Zebra TC21) the reduced height
drops to roughly the width, flipping the portrait check, so the hook fired
Keyboard.dismiss() immediately after the keyboard appeared — Gboard opened
and instantly closed.
Detect rotation from Dimensions.get('screen'), which reflects the physical
display and is unaffected by the keyboard, and react to genuine dimension
changes via a subscription instead of a render-time side effect.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
WalkthroughThe ChangesOrientation Change Detection via Dimensions API
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@CodeRabbit review |
✅ Action performedReview finished.
|
|
Android Build Available Rocket.Chat 4.74.0.109098 Internal App Sharing: https://play.google.com/apps/test/RQQ8k09hlnQ/ahAO29uNQAzJRzXty3AojKakQSnKrSudo0jYYKbfatN-IbDM_fe9PaioJvfTYFOGIN5IothcvOnCrd0iL4tz12IcXQ |
Proposed changes
On some small-screen Android devices (e.g. Zebra TC21, also seen on Android 11), the keyboard would open and
immediately close again the moment you tapped the message composer, making it impossible to type.
The cause was the useCloseKeyboardWhenOrientationChanges hook. It decided "portrait vs landscape" by comparing
the width and height of the safe-area frame, and dismissed the keyboard whenever that orientation flipped.
The problem: with adjustResize + edge-to-edge, that frame shrinks when the keyboard opens. On small screens
the reduced height drops close to the width, so the hook mistook the keyboard opening for a screen rotation
and called Keyboard.dismiss() right after the keyboard appeared.
This PR changes the hook to:
affected by the soft keyboard — so opening the keyboard no longer looks like a rotation.
side effect during render.
The keyboard now stays open when typing, while still dismissing correctly on a genuine device rotation.
Issue(s)
https://rocketchat.atlassian.net/browse/SUP-1055
How to test or reproduce
Screenshots
Types of changes
Checklist
Further comments
Summary by CodeRabbit