Skip to content

Commit 167f8a7

Browse files
authored
TextField - charCount UX change (#982)
* UX change - charCount text color to change to red only when user exceeds maxLength instead of when reaches maxLength. * Update component with new Keyboard constant
1 parent f8b7a63 commit 167f8a7

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/components/chipsInput/__tests__/index.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('ChipsInput', () => {
4141
});
4242

4343
it('should update state - tagIndexToRemove with last tag index', () => {
44-
const pressEvent = {nativeEvent: {key: 'Backspace'}};
44+
const pressEvent = {nativeEvent: {key: Constants.backspaceKey}};
4545
uut.onKeyPress(pressEvent);
4646
expect(uut.state.tagIndexToRemove).toBe(2);
4747
});
@@ -54,7 +54,7 @@ describe('ChipsInput', () => {
5454
});
5555

5656
it('should not update state if there are not tags', () => {
57-
const pressEvent = {nativeEvent: {key: 'Backspace'}};
57+
const pressEvent = {nativeEvent: {key: Constants.backspaceKey}};
5858
_.set(uut.state, 'tags', []);
5959
uut.onKeyPress(pressEvent);
6060
expect(uut.state.tagIndexToRemove).toBe(undefined);
@@ -71,7 +71,7 @@ describe('ChipsInput', () => {
7171
});
7272

7373
it('should not update state if input value is not empty', () => {
74-
const pressEvent = {nativeEvent: {key: 'Backspace'}};
74+
const pressEvent = {nativeEvent: {key: Constants.backspaceKey}};
7575
_.set(uut.state, 'tags', [{}, {}, {}]);
7676
_.set(uut.state, 'value', 'some text');
7777
uut.onKeyPress(pressEvent);
@@ -89,7 +89,7 @@ describe('ChipsInput', () => {
8989
});
9090

9191
it('should not set last tag index if it is already set to last index, instead call remove tag', () => {
92-
const pressEvent = {nativeEvent: {key: 'Backspace'}};
92+
const pressEvent = {nativeEvent: {key: Constants.backspaceKey}};
9393
_.set(uut.state, 'tagIndexToRemove', 2);
9494
uut.onKeyPress(pressEvent);
9595
expect(removeTagSpy).toHaveBeenCalled();

src/components/chipsInput/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ export default class ChipsInput extends BaseComponent {
213213
const tagsCount = _.size(tags);
214214
const keyCode = _.get(event, 'nativeEvent.key');
215215
const hasNoValue = _.isEmpty(value);
216-
const pressedBackspace = Constants.isAndroid || keyCode === 'Backspace';
216+
const pressedBackspace = Constants.isAndroid || keyCode === Constants.backspaceKey;
217217
const hasTags = tagsCount > 0;
218218

219219
if (pressedBackspace) {

src/components/tagsInput/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export default class TagsInput extends BaseComponent {
218218
const tagsCount = _.size(tags);
219219
const keyCode = _.get(event, 'nativeEvent.key');
220220
const hasNoValue = _.isEmpty(value);
221-
const pressedBackspace = Constants.isAndroid || keyCode === 'Backspace';
221+
const pressedBackspace = Constants.isAndroid || keyCode === Constants.backspaceKey;
222222
const hasTags = tagsCount > 0;
223223

224224
if (pressedBackspace) {

0 commit comments

Comments
 (0)