Skip to content

Commit

Permalink
Fixed #2706 - Add panelContainerStyle and panelContainerClassName pro…
Browse files Browse the repository at this point in the history
…perties to TabView
  • Loading branch information
mertsincan committed Mar 29, 2022
1 parent 800d523 commit 3e259d1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
12 changes: 12 additions & 0 deletions components/doc/tabview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,18 @@ template: (options) => {
<td>false</td>
<td>When enabled displays buttons at each side of the tab headers to scroll the tab list.</td>
</tr>
<tr>
<td>panelContainerStyle</td>
<td>object</td>
<td>null</td>
<td>Inline style of the panels container of the tabview.</td>
</tr>
<tr>
<td>panelContainerClassName</td>
<td>string</td>
<td>null</td>
<td>Style class of the panels container of the tabview.</td>
</tr>
</tbody>
</table>
</div>
Expand Down
2 changes: 2 additions & 0 deletions components/lib/tabview/TabView.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export interface TabViewProps {
className?: string;
renderActiveOnly?: boolean;
scrollable?: boolean;
panelContainerStyle?: object;
panelContainerClassName?: string;
onTabChange?(e: TabViewTabChangeParams): void;
onTabClose?(e: TabViewTabCloseParams): void;
}
Expand Down
11 changes: 8 additions & 3 deletions components/lib/tabview/TabView.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ export const TabView = forwardRef((props, ref) => {
}

const createContent = () => {
const className = classNames('p-tabview-panels', props.panelContainerClassName);
const contents = React.Children.map(props.children, (tab, index) => {
if (shouldUseTab(tab, index) && (!props.renderActiveOnly || isSelected(index))) {
const selected = isSelected(index);
Expand All @@ -243,7 +244,7 @@ export const TabView = forwardRef((props, ref) => {
});

return (
<div className="p-tabview-panels">
<div className={className} style={props.panelContainerStyle}>
{contents}
</div>
)
Expand Down Expand Up @@ -334,7 +335,9 @@ TabView.defaultProps = {
renderActiveOnly: true,
onTabChange: null,
onTabClose: null,
scrollable: false
scrollable: false,
panelContainerStyle: null,
panelContainerClassName: null
}

TabView.propTypes /* remove-proptypes */ = {
Expand All @@ -346,5 +349,7 @@ TabView.propTypes /* remove-proptypes */ = {
renderActiveOnly: PropTypes.bool,
onTabChange: PropTypes.func,
onTabClose: PropTypes.func,
scrollable: PropTypes.bool
scrollable: PropTypes.bool,
panelContainerStyle: PropTypes.object,
panelContainerClassName: PropTypes.string
}

0 comments on commit 3e259d1

Please sign in to comment.