Reset textarea height after clear (#10911)

This commit is contained in:
DS Boyce
2026-06-16 09:25:34 -07:00
committed by GitHub
parent 9dc73d2ec7
commit f075187e57
2 changed files with 32 additions and 1 deletions
+10
View File
@@ -34,6 +34,7 @@ import {
} from '#/components/Autocomplete'
import {
AutosizedTextarea,
type AutosizedTextareaHeightApi,
type AutosizedTextareaProps,
} from '#/components/forms/AutosizedTextarea'
import {Span, Text} from '#/components/Typography'
@@ -150,6 +151,13 @@ export function Composer({
*/
const inputScrollSharedValue = useSharedValue(0)
/*
* Imperative handle on the underlying textarea, used to reset its height when
* the input is cleared programmatically (Android doesn't fire
* `onContentSizeChange` in that case).
*/
const heightApiRef = useRef<AutosizedTextareaHeightApi>(null)
/*
* Expose imperative internal API
*/
@@ -160,6 +168,7 @@ export function Composer({
clear: () => {
tapper.inputProps.onChangeText('')
inputScrollSharedValue.value = 0
heightApiRef.current?.resetHeight()
},
insert: tapper.insert,
setAutocompleteAnchor: sift.refs.setAnchor,
@@ -321,6 +330,7 @@ export function Composer({
</View>
)}
<AutosizedTextarea
heightApiRef={heightApiRef}
placeholderTextColor={t.palette.contrast_500}
accessibilityLabel={label}
accessibilityHint={label}