File tree Expand file tree Collapse file tree 6 files changed +45
-1
lines changed
docs/src/components/TextInput
react-native-web/src/exports/TextInput Expand file tree Collapse file tree 6 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ ofProps.propTypes = {
11
11
blurOnSubmit : PropTypes . bool ,
12
12
clearTextOnFocus : PropTypes . bool ,
13
13
defaultValue : PropTypes . string ,
14
+ disabled : PropTypes . bool ,
14
15
editable : PropTypes . bool ,
15
16
keyboardType : PropTypes . string ,
16
17
maxLength : PropTypes . number ,
@@ -52,6 +53,7 @@ export { default as autoCapitalize } from './examples/AutoCapitalize';
52
53
export { default as blurOnSubmit } from './examples/BlurOnSubmit' ;
53
54
export { default as clearButtonMode } from './examples/ClearButtonMode' ;
54
55
export { default as clearTextOnFocus } from './examples/ClearTextOnFocus' ;
56
+ export { default as disabled } from './examples/Disabled' ;
55
57
export { default as editable } from './examples/Editable' ;
56
58
export { default as keyboardType } from './examples/KeyboardType' ;
57
59
export { default as maxLength } from './examples/MaxLength' ;
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ into the field.
56
56
</Story >
57
57
</Preview >
58
58
59
- ### clearTextOnFocus: ?boolean = false
59
+ ### clearTextOnFocus
60
60
61
61
If ` true ` , clears the text field automatically when focused.
62
62
@@ -72,6 +72,16 @@ Provides an initial value that will change when the user starts typing. Useful
72
72
for simple use-cases where you don't want to deal with listening to events and
73
73
updating the value prop to keep the controlled state in sync.
74
74
75
+ ### disabled
76
+
77
+ If ` true ` , the input is disabled. (Web-only)
78
+
79
+ <Preview withSource = ' none' >
80
+ <Story name = " disabled" >
81
+ <Stories.disabled />
82
+ </Story >
83
+ </Preview >
84
+
75
85
### editable
76
86
77
87
If ` false ` , text is not editable (i.e., read-only).
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import { styles } from '../helpers' ;
3
+ import { TextInput , View } from 'react-native' ;
4
+
5
+ export default function Disabled ( ) {
6
+ return (
7
+ < View >
8
+ < TextInput defaultValue = "disabled text input" disabled = { true } style = { styles . textinput } />
9
+ < TextInput
10
+ defaultValue = "disabled multiline text input"
11
+ disabled = { true }
12
+ multiline = { true }
13
+ style = { styles . multiline }
14
+ />
15
+ </ View >
16
+ ) ;
17
+ }
Original file line number Diff line number Diff line change @@ -70,6 +70,18 @@ describe('components/TextInput', () => {
70
70
expect ( input . prop ( 'defaultValue' ) ) . toEqual ( defaultValue ) ;
71
71
} ) ;
72
72
73
+ describe ( 'prop "disabled"' , ( ) => {
74
+ test ( 'value "false"' , ( ) => {
75
+ const input = findNativeInput ( shallow ( < TextInput /> ) ) ;
76
+ expect ( input . prop ( 'disabled' ) ) . toEqual ( undefined ) ;
77
+ } ) ;
78
+
79
+ test ( 'value "true"' , ( ) => {
80
+ const input = findNativeInput ( shallow ( < TextInput disabled = { true } /> ) ) ;
81
+ expect ( input . prop ( 'disabled' ) ) . toEqual ( true ) ;
82
+ } ) ;
83
+ } ) ;
84
+
73
85
describe ( 'prop "editable"' , ( ) => {
74
86
test ( 'value "true"' , ( ) => {
75
87
const input = findNativeInput ( shallow ( < TextInput /> ) ) ;
Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ class TextInput extends React.Component<TextInputProps> {
100
100
autoCorrect = true ,
101
101
autoFocus,
102
102
defaultValue,
103
+ disabled,
103
104
editable = true ,
104
105
keyboardType = 'default' ,
105
106
maxLength,
@@ -151,6 +152,7 @@ class TextInput extends React.Component<TextInputProps> {
151
152
classList : [ classes . textinput ] ,
152
153
defaultValue,
153
154
dir : 'auto' ,
155
+ disabled,
154
156
enterkeyhint : returnKeyType ,
155
157
maxLength,
156
158
onBlur : normalizeEventHandler ( this . _handleBlur ) ,
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ export type TextInputProps = {
27
27
blurOnSubmit ?: boolean ,
28
28
clearTextOnFocus ?: boolean ,
29
29
defaultValue ?: string ,
30
+ disabled ?: boolean ,
30
31
editable ?: boolean ,
31
32
inputAccessoryViewID ?: string ,
32
33
keyboardType ?:
You can’t perform that action at this time.
0 commit comments