From 02e428f88ce673895f18b431c66a4b31fca5cf46 Mon Sep 17 00:00:00 2001 From: CJ Cenizal Date: Mon, 30 Apr 2018 11:06:27 -0700 Subject: [PATCH] Don't track selection state when it's controlled externally. Add more requirements for tabs propType. --- .../__snapshots__/tabbed_content.test.js.snap | 50 +++++++++++-------- .../tabs/tabbed_content/tabbed_content.js | 25 +++++++--- .../tabbed_content/tabbed_content.test.js | 4 +- 3 files changed, 50 insertions(+), 29 deletions(-) diff --git a/src/components/tabs/tabbed_content/__snapshots__/tabbed_content.test.js.snap b/src/components/tabs/tabbed_content/__snapshots__/tabbed_content.test.js.snap index 20af5f7765ba..9932cb2343fe 100644 --- a/src/components/tabs/tabbed_content/__snapshots__/tabbed_content.test.js.snap +++ b/src/components/tabs/tabbed_content/__snapshots__/tabbed_content.test.js.snap @@ -12,12 +12,13 @@ exports[`EuiTabbedContent behavior when selected tab state isn't controlled by t class="euiTab euiTab-isSelected" id="es" role="tab" - title="Elasticsearch" type="button" > + > + Elasticsearch +
{ - const { onTabClick } = this.props; + const { onTabClick, selectedTab: externalSelectedTab } = this.props; if (onTabClick) { onTabClick(selectedTab) } - this.setState({ selectedTab }) + // Only track selection state if it's not controlled externally. + if (!externalSelectedTab) { + this.setState({ selectedTab }) + } }; render() { diff --git a/src/components/tabs/tabbed_content/tabbed_content.test.js b/src/components/tabs/tabbed_content/tabbed_content.test.js index 15006b8438e9..453189fc816e 100644 --- a/src/components/tabs/tabbed_content/tabbed_content.test.js +++ b/src/components/tabs/tabbed_content/tabbed_content.test.js @@ -12,13 +12,13 @@ jest.mock('../../../services/accessibility/html_id_generator', () => ({ const elasticsearchTab = { id: 'es', - title: `Elasticsearch`, + name: `Elasticsearch`, content:

Elasticsearch content

, }; const kibanaTab = { id: 'kibana', - title: `Kibana`, + name: `Kibana`, 'data-test-subj': 'kibanaTab', content:

Kibana content

, };