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: 10731 Focus composer without showing keyboard when users go to chats #32711

Merged
merged 38 commits into from
Sep 30, 2024
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d8eb426
fix: 10731
christianwen Dec 8, 2023
07fdad0
Merge branch 'main' into fix/10731-chat-composer-behavior
christianwen Dec 11, 2023
a5f99b7
lint fix
christianwen Dec 11, 2023
f764d66
resolve conflict
christianwen Jan 2, 2024
f6e2e28
lint fix
christianwen Jan 2, 2024
4b19bdf
fix confict
christianwen Jan 25, 2024
7e930b8
lint fix
christianwen Jan 25, 2024
96e924d
fix conflicts
christianwen Feb 20, 2024
8edc49a
resolve conflict
christianwen Mar 5, 2024
5dc6922
fix focus input
christianwen Mar 5, 2024
b6647b4
focus input on safari
christianwen Mar 5, 2024
432e67e
Merge branch 'main' into fix/10731-chat-composer-behavior
christianwen Apr 8, 2024
e6bfa42
Merge branch 'main' into fix/10731-chat-composer-behavior
christianwen Apr 10, 2024
eb79042
lint fix
christianwen Apr 10, 2024
aec542a
resolve conflicts
christianwen Apr 16, 2024
802f37d
Merge branch 'main' into fix/10731-chat-composer-behavior
christianwen Apr 17, 2024
d036e24
conflicts
christianwen May 7, 2024
dd50857
resolve conflicts
christianwen Aug 13, 2024
b008b05
fix rn to remove autoFill when hide context menu
christianwen Aug 14, 2024
025fa15
type fix
christianwen Aug 14, 2024
c48bb63
resolve conflicts
christianwen Aug 27, 2024
726154d
lint fix
christianwen Aug 27, 2024
5e13e27
Merge branch 'main' into fix/10731-chat-composer-behavior
christianwen Sep 9, 2024
69bc468
remove outdated file
christianwen Sep 9, 2024
c037b05
resolve conflicts
christianwen Sep 13, 2024
3e60d1e
Merge branch 'main' into fix/10731-chat-composer-behavior
christianwen Sep 17, 2024
7ba9d60
clean isFocusedWhileChangingInputMode logic
christianwen Sep 17, 2024
958e9df
conflicts
christianwen Sep 20, 2024
ca23e24
bump rn livemarkdown version
christianwen Sep 20, 2024
c59d44f
use isKeyboardShown
christianwen Sep 24, 2024
fb798c0
Merge branch 'main' into fix/10731-chat-composer-behavior
christianwen Sep 24, 2024
fcac742
update rn-livemarkdown version
christianwen Sep 24, 2024
18055ae
remove CONST
christianwen Sep 24, 2024
381fdff
safari keyboard show
christianwen Sep 25, 2024
e08d442
lint fix
christianwen Sep 25, 2024
2282bf6
remove redundant fix
christianwen Sep 25, 2024
1245315
lint fix
christianwen Sep 25, 2024
33e093e
resolve conflicts
christianwen Sep 30, 2024
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
Prev Previous commit
Next Next commit
focus input on safari
christianwen committed Mar 5, 2024

Verified

This commit was signed with the committer’s verified signature. The key has expired.
danielleadams Danielle Adams
commit b6647b48816e5772850cb754c00d9aff5a7ae796
12 changes: 0 additions & 12 deletions src/components/Composer/index.tsx
Original file line number Diff line number Diff line change
@@ -327,18 +327,6 @@ function Composer(
[numberOfLines, scrollStyleMemo, styles.rtlTextRenderForSafari, style, StyleUtils, isComposerFullSize],
);

useEffect(() => {
if (!showSoftInputOnFocus) {
return;
}
textInput.current?.blur();
// On Safari when changing inputMode from none to text, the keyboard will cover the view
// We need the logic to re-focus to trigger the keyboard to open below the view
setTimeout(() => {
textInput.current?.focus();
}, 2000);
}, [showSoftInputOnFocus]);

return (
<>
<RNTextInput
Original file line number Diff line number Diff line change
@@ -258,6 +258,7 @@ function ComposerWithSuggestions(
const textInputRef = useRef<TextInput | null>(null);
const insertedEmojisRef = useRef<Emoji[]>([]);
const shouldInitFocus = useRef<boolean>(true);
const isFocusedWhileChangingInputMode = useRef<boolean>(false);

const syncSelectionWithOnChangeTextRef = useRef<SyncSelection | null>(null);

@@ -711,6 +712,16 @@ function ComposerWithSuggestions(
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useEffect(() => {
if (!showSoftInputOnFocus || !isFocusedWhileChangingInputMode.current) {
return;
}
// On Safari when changing inputMode from none to text, the keyboard will cover the view
// We need to re-focus to trigger the keyboard to open below the view
isFocusedWhileChangingInputMode.current = false;
textInputRef.current?.focus();
}, [showSoftInputOnFocus]);

return (
<>
<View style={[StyleUtils.getContainerComposeStyles(), styles.textInputComposeBorder]}>
@@ -727,7 +738,12 @@ function ComposerWithSuggestions(
style={[styles.textInputCompose, isComposerFullSize ? styles.textInputFullCompose : styles.textInputCollapseCompose]}
maxLines={maxComposerLines}
onFocus={onFocus}
onBlur={onBlur}
onBlur={(e) => {
if (isFocusedWhileChangingInputMode.current) {
return;
}
onBlur(e);
}}
onClick={setShouldBlockSuggestionCalcToFalse}
onPasteFile={displayFileInModal}
shouldClear={textInputShouldClear}
@@ -751,6 +767,10 @@ function ComposerWithSuggestions(
if (showSoftInputOnFocus) {
return;
}
if (Browser.isMobileSafari()) {
isFocusedWhileChangingInputMode.current = true;
textInputRef.current?.blur();
}

setShowSoftInputOnFocus(true);
}}