Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(android): a composer focused through an app switch stays above the keyboard #20803

Mergedjuliusmarmingemerged 2 commits intomain fromrefs/pull/20803/headmerged by juliusmarminge View on GitHub

Showing 2 changed files with 24 additions and 5 deletions.

x
0 of 2 viewed, 2 left
17 additions and 3 deletionsapps/mobile/src/features/threads/QuestionAttachments.tsxModified
View file
@@ -6,7 +6,7 @@
import { PROVIDER_SEND_TURN_MAX_ATTACHMENTS, type UserInputQuestion } from "@t3tools/contracts";
import { useAtomValue } from "@effect/atom-react";
import { View } from "react-native";
-import { useEffect, useRef, useState } from "react";
+import { useEffect, useEffectEvent, useRef, useState } from "react";
import { ComposerAttachmentButton } from "./ComposerAttachmentButton";
import { ComposerAttachmentStrip } from "../../components/ComposerAttachmentStrip";
import { pickComposerFiles, pickComposerMedia } from "../../lib/composerImages";
@@ -49,6 +49,14 @@
props.requestId,
props.question.id,
]);
+ // A focused input that unmounts never delivers its onBlur, so release focus here or
+ // the screen would keep treating the keyboard as owned by a removed input.
+ const focusedRef = useRef(false);
+ const onInputFocusChange = props.onInputFocusChange;
+ const releaseFocus = useEffectEvent(() => {
+ if (focusedRef.current) onInputFocusChange?.(false);
+ });
+ useEffect(() => () => releaseFocus(), []);
const pickerScope = useRef<{ key: string; active: boolean } | null>(null);
useEffect(() => {
const scope = { key: scopeKey, active: true };
@@ -197,8 +205,14 @@
submitBehavior={props.question.initialAnswer !== undefined ? "newline" : undefined}
editable={!props.disabled}
onChangeText={props.onChangeText}