Skip to content

Commit 185b3d2

Browse files
katallaxieadamTrz
authored andcommitted
Allow to disable clearButton in TextField (#120)
1 parent 902cb20 commit 185b3d2

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

docs/text-field.md

+5
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,8 @@ Custom theme for component. By default provided by the ThemeProvider.
6262
**type:** `string`
6363

6464
Value of TextInput
65+
66+
### `clearButton`
67+
**type** `boolean`
68+
69+
Display the custom button to clear the input. By default the button is shown.

src/components/TextField.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type Props = {
1212
theme: Theme,
1313
placeholder?: string,
1414
value: string,
15+
clearButton?: boolean,
1516
onValueChange?: (text: string) => void,
1617
containerStyle?: StyleObj,
1718
inputStyle?: StyleObj,
@@ -25,6 +26,7 @@ class TextField extends React.Component<Props> {
2526
value,
2627
placeholder,
2728
onValueChange,
29+
clearButton,
2830
theme: {
2931
backgroundColor,
3032
dividerColor,
@@ -53,7 +55,7 @@ class TextField extends React.Component<Props> {
5355
style={[styles.input, { color: textColor }, inputStyle]}
5456
selectionColor={primaryColor}
5557
/>
56-
{value ? (
58+
{value && clearButton !== false ? (
5759
<TouchableOpacity onPress={this.clearInput}>
5860
<Icon
5961
name="ios-close-circle"

0 commit comments

Comments
 (0)