mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-05-27 16:22:20 +00:00
[fix] Add support for caretHidden prop in TextInput
Close #2542 Fix #2541
This commit is contained in:
committed by
Nicolas Gallagher
parent
c350d82427
commit
1c376dbb0c
@@ -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';
|
||||
|
||||
|
||||
@@ -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'),
|
||||
|
||||
Reference in New Issue
Block a user