@@ -10,10 +10,10 @@ import Modal from '@components/Modal';
1010import ScreenWrapper from '@components/ScreenWrapper' ;
1111import Text from '@components/Text' ;
1212import TextInput from '@components/TextInput' ;
13- import type { BaseTextInputRef } from '@components/TextInput/BaseTextInput/types' ;
1413import useLocalize from '@hooks/useLocalize' ;
1514import useResponsiveLayout from '@hooks/useResponsiveLayout' ;
1615import useThemeStyles from '@hooks/useThemeStyles' ;
16+ import { moveSelectionToEnd , scrollToBottom } from '@libs/InputUtils' ;
1717import { getFieldRequiredErrors } from '@libs/ValidationUtils' ;
1818import CONST from '@src/CONST' ;
1919import ONYXKEYS from '@src/ONYXKEYS' ;
@@ -32,6 +32,8 @@ function TextSelectorModal({
3232 required = false ,
3333 customValidate,
3434 enabledWhenOffline = true ,
35+ allowHTML,
36+ autoGrowHeight,
3537 ...rest
3638} : TextSelectorModalProps ) {
3739 const { translate} = useLocalize ( ) ;
@@ -40,11 +42,10 @@ function TextSelectorModal({
4042
4143 const [ currentValue , setValue ] = useState ( value ) ;
4244
43- const inputRef = useRef < BaseTextInputRef | null > ( null ) ;
45+ const inputRef = useRef < TextInputType | null > ( null ) ;
4446 const inputValueRef = useRef ( value ) ;
4547 const focusTimeoutRef = useRef < NodeJS . Timeout | null > ( null ) ;
46-
47- const inputCallbackRef = ( ref : BaseTextInputRef | null ) => {
48+ const inputCallbackRef = ( ref : TextInputType | null ) => {
4849 inputRef . current = ref ;
4950 } ;
5051
@@ -97,7 +98,11 @@ function TextSelectorModal({
9798 focusTimeoutRef . current = setTimeout ( ( ) => {
9899 if ( inputRef . current && isVisible ) {
99100 inputRef . current . focus ( ) ;
100- ( inputRef . current as TextInputType ) . setSelection ?.( inputValueRef . current ?. length ?? 0 , inputValueRef . current ?. length ?? 0 ) ;
101+ inputRef . current . setSelection ?.( inputValueRef . current ?. length ?? 0 , inputValueRef . current ?. length ?? 0 ) ;
102+ if ( autoGrowHeight ) {
103+ scrollToBottom ( inputRef . current ) ;
104+ moveSelectionToEnd ( inputRef . current ) ;
105+ }
101106 }
102107 return ( ) => {
103108 if ( ! focusTimeoutRef . current || ! isVisible ) {
@@ -106,7 +111,7 @@ function TextSelectorModal({
106111 clearTimeout ( focusTimeoutRef . current ) ;
107112 } ;
108113 } , CONST . ANIMATED_TRANSITION ) ;
109- } , [ isVisible ] ) ,
114+ } , [ isVisible , autoGrowHeight ] ) ,
110115 ) ;
111116
112117 const handleSubmit = useCallback (
@@ -155,6 +160,7 @@ function TextSelectorModal({
155160 shouldHideFixErrorsAlert
156161 addBottomSafeAreaPadding
157162 enterKeyEventListenerPriority = { 0 }
163+ allowHTML = { allowHTML }
158164 >
159165 { ! ! subtitle && (
160166 < View style = { styles . pb4 } >
@@ -169,6 +175,7 @@ function TextSelectorModal({
169175 // eslint-disable-next-line react/jsx-props-no-spreading
170176 { ...rest }
171177 inputID = { rest . inputID }
178+ autoGrowHeight = { autoGrowHeight }
172179 />
173180 </ FormProvider >
174181 </ ScreenWrapper >
0 commit comments