Skip to content

Commit

Permalink
Fixed #1079 - Change the type of the 'header' property on TabPanel
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Mar 10, 2020
1 parent 59d57fc commit 18e61d7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/components/tabview/TabView.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';

interface TabPanelProps {
header?: string;
header?: any;
leftIcon?: string;
rightIcon?: string;
disabled?: boolean;
Expand Down
22 changes: 11 additions & 11 deletions src/components/tabview/TabView.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import classNames from 'classnames';
import UniqueComponentId from '../utils/UniqueComponentId';

export class TabPanel extends Component {

static defaultProps = {
header: null,
leftIcon: null,
Expand All @@ -17,7 +17,7 @@ export class TabPanel extends Component {
}

static propTypes = {
header: PropTypes.string,
header: PropTypes.any,
leftIcon: PropTypes.string,
rightIcon: PropTypes.string,
disabled: PropTypes.bool,
Expand All @@ -26,7 +26,7 @@ export class TabPanel extends Component {
contentStyle: PropTypes.object,
contentClassName: PropTypes.string
};

}

export class TabView extends Component {
Expand All @@ -48,7 +48,7 @@ export class TabView extends Component {
renderActiveOnly: PropTypes.bool,
onTabChange: PropTypes.func
};

constructor(props) {
super(props);
if (!this.props.onTabChange) {
Expand All @@ -65,7 +65,7 @@ export class TabView extends Component {

return (activeIndex === index);
}

onTabHeaderClick(event, tab, index) {
if (!tab.props.disabled) {
if (this.props.onTabChange) {
Expand All @@ -80,7 +80,7 @@ export class TabView extends Component {

event.preventDefault();
}

renderTabHeader(tab, index) {
const selected = this.isSelected(index);
const className = classNames(tab.props.headerClassName, 'p-unselectable-text', {'p-tabview-selected p-highlight': selected, 'p-disabled': tab.props.disabled});
Expand All @@ -105,17 +105,17 @@ export class TabView extends Component {
})
);
}

renderNavigator() {
const headers = this.renderTabHeaders();

return (
<ul className="p-tabview-nav p-reset" role="tablist">
{headers}
</ul>
);
}

renderContent() {
const contents = React.Children.map(this.props.children, (tab, index) => {
if (!this.props.renderActiveOnly || this.isSelected(index)) {
Expand Down Expand Up @@ -148,12 +148,12 @@ export class TabView extends Component {
const className = classNames('p-tabview p-component p-tabview-top', this.props.className)
const navigator = this.renderNavigator();
const content = this.renderContent();

return (
<div id={this.props.id} className={className} style={this.props.style}>
{navigator}
{content}
</div>
);
}
}
}

0 comments on commit 18e61d7

Please sign in to comment.