[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} rows={3}
style={styles.multiline} style={styles.multiline}
/> />
<TextInput
caretHidden
defaultValue="caretHidden"
style={styles.textinput}
/>
</View> </View>
</Example> </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"', () => { describe('prop "clearTextOnFocus"', () => {
const defaultValue = 'defaultValue'; const defaultValue = 'defaultValue';
+6 -1
View File
@@ -99,6 +99,7 @@ const TextInput: React.AbstractComponent<
autoCompleteType, autoCompleteType,
autoCorrect = true, autoCorrect = true,
blurOnSubmit, blurOnSubmit,
caretHidden,
clearTextOnFocus, clearTextOnFocus,
dir, dir,
editable, editable,
@@ -402,7 +403,8 @@ const TextInput: React.AbstractComponent<
{ '--placeholderTextColor': placeholderTextColor }, { '--placeholderTextColor': placeholderTextColor },
styles.textinput$raw, styles.textinput$raw,
styles.placeholder, styles.placeholder,
props.style props.style,
caretHidden && styles.caretHidden
]; ];
supportedProps.type = multiline ? undefined : type; supportedProps.type = multiline ? undefined : type;
@@ -448,6 +450,9 @@ const styles = StyleSheet.create({
}, },
placeholder: { placeholder: {
placeholderTextColor: 'var(--placeholderTextColor)' placeholderTextColor: 'var(--placeholderTextColor)'
},
caretHidden: {
caretColor: 'transparent'
} }
}); });
@@ -25,6 +25,7 @@ export type TextInputProps = {
autoCorrect?: ?boolean, autoCorrect?: ?boolean,
autoFocus?: ?boolean, autoFocus?: ?boolean,
blurOnSubmit?: ?boolean, blurOnSubmit?: ?boolean,
caretHidden?: ?boolean,
clearTextOnFocus?: ?boolean, clearTextOnFocus?: ?boolean,
defaultValue?: ?string, defaultValue?: ?string,
dir?: ?('auto' | 'ltr' | 'rtl'), dir?: ?('auto' | 'ltr' | 'rtl'),