Skip to content

Commit 243b306

Browse files
authored
Merge pull request #100 from fhlavac/fix-tabs
Fix tabs
2 parents 6447567 + a355572 commit 243b306

File tree

8 files changed

+14
-14
lines changed

8 files changed

+14
-14
lines changed

packages/mui-component-mapper/demo/demo-schemas/sandbox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const output = {
1010
{
1111
title: 'Tab 1',
1212
description: 'Text boxes and text areas',
13-
key: '553',
13+
name: '553',
1414
fields: [
1515
{
1616
title: 'Text boxes',

packages/mui-component-mapper/src/form-fields/tabs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import AppBar from '@material-ui/core/AppBar';
44
import Tabs from '@material-ui/core/Tabs';
55
import Tab from '@material-ui/core/Tab';
66

7-
const renderTabHeader = items => items.map(({ title, key }) => <Tab key={ key } label={ title } />);
8-
const renderTabContet = ({ key, fields }, formOptions) => <Fragment key={ key }>{ formOptions.renderForm(fields, formOptions) }</Fragment>;
7+
const renderTabHeader = items => items.map(({ title, key, name }) => <Tab key={ name || key } label={ title } />);
8+
const renderTabContet = ({ key, name, fields }, formOptions) => <Fragment key={ name || key }>{ formOptions.renderForm(fields, formOptions) }</Fragment>;
99

1010
class FormTabs extends Component {
1111
state = {

packages/pf3-component-mapper/demo/demo-schemas/sandbox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const output = {
1010
{
1111
title: 'Tab 1',
1212
description: 'Text boxes and text areas',
13-
key: '553',
13+
name: '553',
1414
fields: [
1515
{
1616
title: 'Text boxes',

packages/pf3-component-mapper/src/form-fields/tabs.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ import get from 'lodash/get';
33
import PropTypes from 'prop-types';
44
import { TabContainer, Nav, NavItem, TabContent, TabPane, Icon } from 'patternfly-react';
55

6-
const renderTabHeader = (items, formOptions) => items.map(({ title, key, validateFields = []}, index) => {
6+
const renderTabHeader = (items, formOptions) => items.map(({ title, key, name, validateFields = []}, index) => {
77
const errors = formOptions.getState().errors;
88
const hasError = validateFields.find(name => !!get(errors, name));
99
return (
10-
<NavItem key={ key } eventKey={ index }>
10+
<NavItem key={ name || key } eventKey={ index }>
1111
{ hasError && <Icon style={{ marginRight: 8, color: '#CC0000' }} type="fa" name="exclamation-circle" /> }
1212
{ title }
1313
</NavItem>
1414
);
1515
});
1616
const renderTabContent = (items, formOptions) =>
17-
items.map(({ key, fields }, index) =>
18-
<TabPane key={ key } eventKey={ index } >{ formOptions.renderForm(fields, formOptions) }</TabPane>);
17+
items.map(({ key, name, fields }, index) =>
18+
<TabPane key={ name || key } eventKey={ index } >{ formOptions.renderForm(fields, formOptions) }</TabPane>);
1919

2020
const FormTabs = ({ fields, formOptions }) => (
2121
<TabContainer id="basic-tabs-pf" defaultActiveKey={ 0 }>

packages/pf4-component-mapper/demo/demo-schemas/sandbox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const output = {
2929
{
3030
title: 'Tab 1',
3131
description: 'Text boxes and text areas',
32-
key: '553',
32+
name: '553',
3333
fields: [
3434
{
3535
title: 'Text boxes',

packages/pf4-component-mapper/src/form-fields/tabs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class FormTabs extends React.Component {
1616
};
1717

1818
renderTabItems = (fields, formOptions) => fields.map(({ key, fields, title, name }, index) => (
19-
<Tab key={ key || name } eventKey={ index } title={ title }>
19+
<Tab key={ name || key } eventKey={ index } title={ title }>
2020
<div className='pf-c-form'>
2121
{ formOptions.renderForm(fields, formOptions) }
2222
</div>

packages/pf4-component-mapper/src/tests/__snapshots__/tabs.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ exports[`Tabs component should render tabs correctly 1`] = `
1313
>
1414
<ForwardRef
1515
eventKey={0}
16-
key="cosiKey"
16+
key="cosiName"
1717
title="cosiTitle"
1818
>
1919
<div
@@ -26,7 +26,7 @@ exports[`Tabs component should render tabs correctly 1`] = `
2626
</ForwardRef>
2727
<ForwardRef
2828
eventKey={1}
29-
key="cosiKey2"
29+
key="cosiName2"
3030
title="cosiTitle2"
3131
>
3232
<div

packages/react-renderer-demo/src/common/examples-definitions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ export const baseExamples = [{
232232
{
233233
component: componentTypes.TAB_ITEM,
234234
validateFields: [ 'apple' ],
235-
key: '1',
235+
name: '1',
236236
title: 'Fruits',
237237
description: 'Here you can find fruits',
238238
fields: [
@@ -249,7 +249,7 @@ export const baseExamples = [{
249249
},
250250
{
251251
component: componentTypes.TAB_ITEM,
252-
key: '2',
252+
name: '2',
253253
title: 'Vegetables',
254254
description: 'Here you can find vegetables',
255255
fields: [

0 commit comments

Comments
 (0)