From e209a30937a47e0fa6df66c849b7e277dae8976e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20H=C3=B8egh?= Date: Tue, 15 Sep 2020 09:53:06 +0200 Subject: [PATCH] fix: fix #tabs `prerender` if key is given as a number --- packages/dnb-ui-lib/src/components/tabs/Tabs.js | 2 +- .../dnb-ui-lib/src/components/tabs/__tests__/Tabs.test.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/dnb-ui-lib/src/components/tabs/Tabs.js b/packages/dnb-ui-lib/src/components/tabs/Tabs.js index a07d070b710..9daf755f6d3 100644 --- a/packages/dnb-ui-lib/src/components/tabs/Tabs.js +++ b/packages/dnb-ui-lib/src/components/tabs/Tabs.js @@ -419,7 +419,7 @@ export default class Tabs extends React.PureComponent { const cachedContent = Object.entries(this._cache).map( ([key, { content }]) => { const params = {} - if (key !== selected_key) { + if (key !== String(selected_key)) { params.hidden = true params['aria-hidden'] = true } diff --git a/packages/dnb-ui-lib/src/components/tabs/__tests__/Tabs.test.js b/packages/dnb-ui-lib/src/components/tabs/__tests__/Tabs.test.js index 20846f64ae8..9abff2e1834 100644 --- a/packages/dnb-ui-lib/src/components/tabs/__tests__/Tabs.test.js +++ b/packages/dnb-ui-lib/src/components/tabs/__tests__/Tabs.test.js @@ -200,10 +200,10 @@ describe('A single Tab component', () => { data={[ { title: 'One', - key: 'one', + key: 1, content: 'Content one' }, - { title: 'Two', key: 'two', content: 'Content two' } + { title: 'Two', key: 2, content: 'Content two' } ]} /> )