Skip to content

Commit

Permalink
fix: fix the problem that children of TextInput would be cleared when…
Browse files Browse the repository at this point in the history
… setting the selection prop
  • Loading branch information
ZhuoYitao committed Dec 29, 2023
1 parent b5e08e8 commit 513259f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,8 @@ function InternalTextInput(props: Props): React.Node {
? props.value
: typeof props.defaultValue === 'string'
? props.defaultValue
: typeof props.value === 'undefined'
? null
: '';

// This is necessary in case native updates the text and JS decides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ describe('TextInput tests', () => {
rejectResponderTermination={true}
selection={null}
submitBehavior="blurAndSubmit"
text=""
text={null}
textContentType="emailAddress"
underlineColorAndroid="transparent"
/>
Expand Down Expand Up @@ -244,7 +244,7 @@ describe('TextInput', () => {
rejectResponderTermination={true}
selection={null}
submitBehavior="blurAndSubmit"
text=""
text={null}
underlineColorAndroid="transparent"
/>
`);
Expand Down Expand Up @@ -291,7 +291,7 @@ describe('TextInput compat with web', () => {
selection={null}
submitBehavior="blurAndSubmit"
testID="testID"
text=""
text={null}
underlineColorAndroid="transparent"
/>
`);
Expand Down Expand Up @@ -423,7 +423,7 @@ describe('TextInput compat with web', () => {
role="main"
selection={null}
submitBehavior="blurAndSubmit"
text=""
text={null}
underlineColorAndroid="transparent"
/>
`);
Expand Down Expand Up @@ -475,7 +475,7 @@ describe('TextInput compat with web', () => {
}
}
submitBehavior="blurAndSubmit"
text=""
text={null}
underlineColorAndroid="transparent"
/>
`);
Expand Down

0 comments on commit 513259f

Please sign in to comment.