|
1 | 1 | import _ from 'lodash';
|
2 | 2 | import PropTypes from 'prop-types';
|
3 | 3 | import React, {Component} from 'react';
|
4 |
| -import ReactNative, {NativeModules, StyleSheet, ViewPropTypes, Image, DeviceEventEmitter} from 'react-native'; |
| 4 | +import ReactNative, {NativeModules, StyleSheet, ViewPropTypes, Image} from 'react-native'; |
5 | 5 | import {Constants} from '../../helpers';
|
6 | 6 | import {Colors, BorderRadiuses, ThemeManager, Typography} from '../../style';
|
7 | 7 | import Assets from '../../assets';
|
@@ -105,17 +105,10 @@ class ChipsInput extends Component {
|
105 | 105 | const textInputHandle = ReactNative.findNodeHandle(this.input);
|
106 | 106 | if (textInputHandle && NativeModules.TextInputDelKeyHandler) {
|
107 | 107 | NativeModules.TextInputDelKeyHandler.register(textInputHandle);
|
108 |
| - DeviceEventEmitter.addListener('onBackspacePress', this.onKeyPress); |
109 | 108 | }
|
110 | 109 | }
|
111 | 110 | }
|
112 | 111 |
|
113 |
| - componentWillUnmount() { |
114 |
| - if (Constants.isAndroid) { |
115 |
| - DeviceEventEmitter.removeListener('onBackspacePress', this.onKeyPress); |
116 |
| - } |
117 |
| - } |
118 |
| - |
119 | 112 | static getDerivedStateFromProps(nextProps, prevState) {
|
120 | 113 | if (nextProps.tags !== prevState.initialTags) {
|
121 | 114 | return {
|
@@ -169,10 +162,10 @@ class ChipsInput extends Component {
|
169 | 162 | this.setState({tagIndexToRemove: tagIndex});
|
170 | 163 | }
|
171 | 164 |
|
172 |
| - onChangeText = (value) => { |
| 165 | + onChangeText = _.debounce((value) => { |
173 | 166 | this.setState({value, tagIndexToRemove: undefined});
|
174 | 167 | _.invoke(this.props, 'onChangeText', value);
|
175 |
| - } |
| 168 | + }, 0); |
176 | 169 |
|
177 | 170 | onTagPress(index) {
|
178 | 171 | const {onTagPress} = this.props;
|
@@ -212,7 +205,7 @@ class ChipsInput extends Component {
|
212 | 205 | const tagsCount = _.size(tags);
|
213 | 206 | const keyCode = _.get(event, 'nativeEvent.key');
|
214 | 207 | const hasNoValue = _.isEmpty(value);
|
215 |
| - const pressedBackspace = Constants.isAndroid || keyCode === Constants.backspaceKey; |
| 208 | + const pressedBackspace = keyCode === Constants.backspaceKey; |
216 | 209 | const hasTags = tagsCount > 0;
|
217 | 210 |
|
218 | 211 | if (pressedBackspace) {
|
|
0 commit comments