-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Fix - Android - Chat - Composer is no longer highlighted after rotation, emoji picker does not open #88122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mjasikowski
merged 2 commits into
Expensify:main
from
software-mansion-labs:fix/landscape-transition-keyboard-focus
Apr 17, 2026
Merged
Fix - Android - Chat - Composer is no longer highlighted after rotation, emoji picker does not open #88122
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import useIsInLandscapeMode from '@hooks/useIsInLandscapeMode'; | ||
| import usePrevious from '@hooks/usePrevious'; | ||
| import type {UseLandscapeOnBlurProxy} from './types'; | ||
|
|
||
| // During a portrait → landscape rotation the input briefly ends up behind the keyboard | ||
| // while KeyboardAvoidingView catches up, and native blurs it as a result. When that blur | ||
| // fires we re-focus the input after a short delay — long enough for KAV to reposition so | ||
| // the input is on-screen again, otherwise the re-focus gets clobbered by the same issue. | ||
| const ROTATION_REFOCUS_DELAY_MS = 100; | ||
|
|
||
| const useLandscapeOnBlurProxy: UseLandscapeOnBlurProxy = (inputRef, onBlur) => { | ||
| const isInLandscapeMode = useIsInLandscapeMode(); | ||
| const prevIsInLandscapeMode = usePrevious(isInLandscapeMode); | ||
|
|
||
| return (e) => { | ||
| if (prevIsInLandscapeMode !== isInLandscapeMode && isInLandscapeMode) { | ||
| setTimeout(() => inputRef.current?.focus?.(), ROTATION_REFOCUS_DELAY_MS); | ||
| } | ||
| onBlur?.(e); | ||
| }; | ||
| }; | ||
|
|
||
| export default useLandscapeOnBlurProxy; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import type {UseLandscapeOnBlurProxy} from './types'; | ||
|
|
||
| // The rotation-refocus workaround is only needed on Android — iOS and web don't lose focus | ||
| // when the orientation flips, so we pass the caller's onBlur through unchanged. | ||
| const useLandscapeOnBlurProxy: UseLandscapeOnBlurProxy = (_inputRef, onBlur) => onBlur; | ||
|
|
||
| export default useLandscapeOnBlurProxy; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import type {RefObject} from 'react'; | ||
| import type {FocusEvent} from 'react-native'; | ||
|
|
||
| type FocusableRef = RefObject<{focus?: () => void} | null>; | ||
|
|
||
| type OnBlurHandler = (e: FocusEvent) => void; | ||
|
|
||
| type UseLandscapeOnBlurProxy = (inputRef: FocusableRef, onBlur?: OnBlurHandler) => OnBlurHandler | undefined; | ||
|
|
||
| export type {FocusableRef, OnBlurHandler, UseLandscapeOnBlurProxy}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current condition refocuses on any blur while
prevIsInLandscapeMode !== isInLandscapeMode && isInLandscapeMode, not specifically the blur caused by rotation. That means after rotating to landscape, a normal user blur (e.g., tapping outside to dismiss the keyboard) can be immediately undone by the timeout focus, causing the keyboard to pop back up and making blur behavior unreliable. This is especially visible when the OS does not emit an automatic blur during rotation, because the first intentional blur gets treated as a rotation blur.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While technically true, this is designed to address a specific case because that blur occurs on android. Couldn't reproduce scenario described above while testing.