[fix] Add support for caretHidden prop in TextInput

Close #2542
Fix #2541
This commit is contained in:
Aswin S
2023-06-22 14:32:04 +05:30
committed by Nicolas Gallagher
parent c350d82427
commit 1c376dbb0c
4 changed files with 20 additions and 1 deletions
@@ -75,6 +75,11 @@ export default function TextInputPage() {
rows={3}
style={styles.multiline}
/>
<TextInput
caretHidden
defaultValue="caretHidden"
style={styles.textinput}
/>
</View>
</Example>
);
@@ -105,6 +105,14 @@ describe('components/TextInput', () => {
});
});
describe('prop "caretHidden"', () => {
test('value "true"', () => {
const { container } = render(<TextInput caretHidden />);
const style = window.getComputedStyle(container.firstChild);
expect(style.caretColor).toEqual('transparent');
});
});
describe('prop "clearTextOnFocus"', () => {
const defaultValue = 'defaultValue';
+6 -1
View File
@@ -99,6 +99,7 @@ const TextInput: React.AbstractComponent<
autoCompleteType,
autoCorrect = true,
blurOnSubmit,
caretHidden,
clearTextOnFocus,
dir,
editable,
@@ -402,7 +403,8 @@ const TextInput: React.AbstractComponent<
{ '--placeholderTextColor': placeholderTextColor },
styles.textinput$raw,
styles.placeholder,
props.style
props.style,
caretHidden && styles.caretHidden
];
supportedProps.type = multiline ? undefined : type;
@@ -448,6 +450,9 @@ const styles = StyleSheet.create({
},
placeholder: {
placeholderTextColor: 'var(--placeholderTextColor)'
},
caretHidden: {
caretColor: 'transparent'
}
});
@@ -25,6 +25,7 @@ export type TextInputProps = {
autoCorrect?: ?boolean,
autoFocus?: ?boolean,
blurOnSubmit?: ?boolean,
caretHidden?: ?boolean,
clearTextOnFocus?: ?boolean,
defaultValue?: ?string,
dir?: ?('auto' | 'ltr' | 'rtl'),