Skip to content
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

Fix - The Composer isn't getting focus again after the attachment modal is dismissed #53328

Merged
merged 3 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/libs/focusComposerWithDelay/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {InteractionManager} from 'react-native';
import ComposerFocusManager from '@libs/ComposerFocusManager';
import isWindowReadyToFocus from '@libs/isWindowReadyToFocus';
import * as EmojiPickerAction from '@userActions/EmojiPickerAction';
Expand Down Expand Up @@ -31,7 +32,8 @@ function focusComposerWithDelay(textInput: InputType | null): FocusComposerWithD
if (!textInput) {
return;
}
textInput.focus();
// When the closing modal has a focused text input focus() needs a delay to properly work.
InteractionManager.runAfterInteractions(() => textInput.focus());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know why this focus isn't applied to mobile?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might help

// We want to focus or refocus the input when a modal has been closed or the underlying screen is refocused.
// We avoid doing this on native platforms since the software keyboard popping
// open creates a jarring and broken UX.

if (forcedSelectionRange) {
setTextInputSelection(textInput, forcedSelectionRange);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,12 @@ function ReportActionCompose({
raiseIsScrollLikelyLayoutTriggered={raiseIsScrollLikelyLayoutTriggered}
onAddActionPressed={onAddActionPressed}
onItemSelected={onItemSelected}
onCanceledAttachmentPicker={() => {
if (!shouldFocusInputOnScreenFocus) {
return;
}
focus();
}}
actionButtonRef={actionButtonRef}
shouldDisableAttachmentItem={hasExceededMaxCommentLength}
/>
Expand Down
Loading