From 365b44aff5f7823d9f47020fbc0a070b80db7361 Mon Sep 17 00:00:00 2001 From: Ben McKernan Date: Fri, 22 Feb 2019 14:19:03 +0100 Subject: [PATCH] fix(tab): Set initial tabIndex state to -1 (#690) --- packages/tab/index.tsx | 1 + test/unit/tab/index.test.tsx | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/packages/tab/index.tsx b/packages/tab/index.tsx index 767062dfa..0d63cf797 100644 --- a/packages/tab/index.tsx +++ b/packages/tab/index.tsx @@ -72,6 +72,7 @@ export default class Tab extends React.Component { 'aria-selected': false, 'activateIndicator': false, 'previousIndicatorClientRect': this.props.previousIndicatorClientRect, + 'tabIndex': -1, }; componentDidMount() { diff --git a/test/unit/tab/index.test.tsx b/test/unit/tab/index.test.tsx index 6ecfc32c1..5787a66d5 100644 --- a/test/unit/tab/index.test.tsx +++ b/test/unit/tab/index.test.tsx @@ -29,6 +29,16 @@ test('adds the active class if props.active is true on mount', () => { assert.isTrue(wrapper.hasClass('mdc-tab--active')); }); +test('sets the tabIndex to 0 if props.active is true on mount', () => { + const wrapper = shallow(); + assert.equal(wrapper.prop('tabIndex'), 0); +}); + +test('sets the tabIndex to -1 if props.active is false on mount', () => { + const wrapper = shallow(); + assert.equal(wrapper.prop('tabIndex'), -1); +}); + test('adds a class from state.classList', () => { const wrapper = shallow(); wrapper.setState({classList: new Set(['test-class'])});