Skip to content
This repository was archived by the owner on Jun 13, 2023. It is now read-only.

Commit 62606f4

Browse files
committed
Allow tag creation trigger to be custom.
1 parent 71c0c85 commit 62606f4

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

README.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,19 @@ const UselessComponent = () => (
4141

4242
## Props
4343

44-
| PropName | Description | Default |
45-
| ------------------- | ------------------------------------------ | -------- |
46-
| initialText | The input element's text | |
47-
| initialTags | ['the', 'initial', 'tags'] | |
48-
| onChangeTags | Fires when tags are added or removed | |
49-
| maxNumberOfTags | The max number of tags that can be entered | infinity |
50-
| onTagPress | Fires when tags are pressed | |
51-
| readonly | Tags cannot be modified | false |
52-
| deleteTagOnPress | Remove the tag when pressed | true |
53-
| containerStyle | Style | |
54-
| style | Style (`containerStyle` alias) | |
55-
| inputContainerStyle | Style | |
56-
| inputStyle | Style | |
57-
| tagContainerStyle | Style | |
58-
| tagTextStyle | Style | |
44+
| PropName | Description | Default |
45+
| ------------------- | ------------------------------------------ | --------------- |
46+
| initialText | The input element's text | |
47+
| initialTags | ['the', 'initial', 'tags'] | |
48+
| createTagOnString | Triggers new tag creation | [",", ".", " "] |
49+
| onChangeTags | Fires when tags are added or removed | |
50+
| maxNumberOfTags | The max number of tags that can be entered | infinity |
51+
| onTagPress | Fires when tags are pressed | |
52+
| readonly | Tags cannot be modified | false |
53+
| deleteTagOnPress | Remove the tag when pressed | true |
54+
| containerStyle | Style | |
55+
| style | Style (`containerStyle` alias) | |
56+
| inputContainerStyle | Style | |
57+
| inputStyle | Style | |
58+
| tagContainerStyle | Style | |
59+
| tagTextStyle | Style | |

Tags/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Tags extends React.Component {
3939
);
4040
} else if (
4141
text.length > 1 &&
42-
(text.slice(-1) === " " || text.slice(-1) === ",") &&
42+
this.props.createTagOnString.includes(text.slice(-1)) &&
4343
!(this.state.tags.indexOf(text.slice(0, -1).trim()) > -1)
4444
) {
4545
this.setState(
@@ -119,6 +119,7 @@ class Tags extends React.Component {
119119
Tags.defaultProps = {
120120
initialTags: [],
121121
initialText: " ",
122+
createTagOnString: [",", " "],
122123
readonly: false,
123124
deleteOnTagPress: true,
124125
maxNumberOfTags: Number.POSITIVE_INFINITY
@@ -127,6 +128,7 @@ Tags.defaultProps = {
127128
Tags.propTypes = {
128129
initialText: PropTypes.string,
129130
initialTags: PropTypes.arrayOf(PropTypes.string),
131+
createTagOnString: PropTypes.array,
130132
onChangeTags: PropTypes.func,
131133
readonly: PropTypes.bool,
132134
maxNumberOfTags: PropTypes.number,

0 commit comments

Comments
 (0)