diff --git a/.gitignore b/.gitignore index ae1c1e3..c82240c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ dist example/bundle.js example/bundle.js.map coverage +/.idea/ diff --git a/lib/ReactTags.js b/lib/ReactTags.js index 97a4fa4..5f91a42 100644 --- a/lib/ReactTags.js +++ b/lib/ReactTags.js @@ -156,7 +156,11 @@ class ReactTags extends React.Component { pressUpKey.call(this, e) } - if (e.key === KEYS.DOWN_ARROW || e.key === KEYS.DOWN_ARROW_COMPAT) { + if (e.key === KEYS.DOWN_ARROW || e.key === KEYS.DOWN_ARROW_COMPAT || e.key === KEYS.TAB) { + pressDownKey.call(this, e) + } + + if (!this.props.allowNew && this.state.options.length && this.state.index === -1) { pressDownKey.call(this, e) } } @@ -308,7 +312,7 @@ ReactTags.defaultProps = { suggestionsTransform: null, autoresize: true, classNames: CLASS_NAMES, - delimiters: [KEYS.TAB, KEYS.ENTER], + delimiters: [KEYS.ENTER], minQueryLength: 2, maxSuggestionsLength: 6, allowNew: false, diff --git a/package.json b/package.json index 90b4001..13cb166 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "Serhiy Yefremenko", "Paul Shannon", "Herdis Maria", - "Sibiraj S" + "Sibiraj S", + "Metagûsto" ], "license": "MIT", "repository": "https://github.com/i-like-robots/react-tags", diff --git a/spec/ReactTags.spec.js b/spec/ReactTags.spec.js index 8466c9c..400bf02 100644 --- a/spec/ReactTags.spec.js +++ b/spec/ReactTags.spec.js @@ -365,16 +365,11 @@ describe('React Tags', () => { key('ArrowDown') - expect(input.getAttribute('aria-activedescendant')).toEqual(results[0].id) - expect(results[0].className).toMatch(/is-active/) + expect(input.getAttribute('aria-activedescendant')).toEqual(results[1].id) + expect(results[1].className).toMatch(/is-active/) key('ArrowDown', 'ArrowDown') - expect(input.getAttribute('aria-activedescendant')).toEqual(results[2].id) - expect(results[2].className).toMatch(/is-active/) - - key('ArrowDown') - expect(input.getAttribute('aria-activedescendant')).toEqual(results[0].id) expect(results[0].className).toMatch(/is-active/) @@ -412,7 +407,7 @@ describe('React Tags', () => { sinon.assert.notCalled(props.onAddition) - type(query); key('ArrowDown', 'ArrowDown', 'Enter') + type(query); key('ArrowDown', 'Enter') sinon.assert.calledOnce(props.onAddition) sinon.assert.calledWith(props.onAddition, { id: 196, name: 'United Kingdom' })