diff --git a/src/isFocusableInput.js b/src/isFocusableInput.js index 72c2b2c..5bc3a73 100644 --- a/src/isFocusableInput.js +++ b/src/isFocusableInput.js @@ -3,6 +3,6 @@ * Predicate to identify inputs that can have focus() called on them */ const isFocusableInput = (wtf: any) => - !!(wtf && typeof wtf.focus === 'function') + !!(wtf && typeof wtf.focus === 'function' && wtf.tagName !== 'BUTTON') export default isFocusableInput diff --git a/src/isFocusableInput.test.js b/src/isFocusableInput.test.js index 9e9276b..213cea9 100644 --- a/src/isFocusableInput.test.js +++ b/src/isFocusableInput.test.js @@ -14,4 +14,8 @@ describe('isFocusableInput', () => { it('should return true for an object with a focus method', () => { expect(isFocusableInput({ focus: () => {} })).toBe(true) }) + + it('should return false for a button', () => { + expect(isFocusableInput(document.createElement('button'))).toBe(false) + }) })