Skip to content

Commit

Permalink
fix(Tab): implement renderButton support (#7418)
Browse files Browse the repository at this point in the history
* fix(Tab): implement renderButton support

* chore: update snapshot

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
emyarod and kodiakhq[bot] authored Dec 8, 2020
1 parent 1c7fbf6 commit b39e260
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5046,6 +5046,9 @@ Map {
"type": "func",
},
"renderAnchor": [Function],
"renderButton": Object {
"type": "func",
},
"renderContent": Object {
"type": "func",
},
Expand Down
10 changes: 7 additions & 3 deletions packages/react/src/components/Tab/Tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export default class Tab extends React.Component {
* side router libraries.
**/
renderAnchor: deprecate(PropTypes.func),
renderButton: PropTypes.func,

/*
* An optional parameter to allow overriding the content rendering.
Expand Down Expand Up @@ -119,7 +120,8 @@ export default class Tab extends React.Component {
onClick,
onKeyDown,
// TODO: rename renderAnchor to renderButton in next major version
renderAnchor: renderButton,
renderAnchor,
renderButton,
renderContent, // eslint-disable-line no-unused-vars
...other
} = this.props;
Expand Down Expand Up @@ -153,6 +155,8 @@ export default class Tab extends React.Component {
},
};

const renderElement = renderButton || renderAnchor;

return (
<li
{...other}
Expand All @@ -176,8 +180,8 @@ export default class Tab extends React.Component {
onKeyDown(evt);
}}
role="presentation">
{renderButton ? (
renderButton(buttonProps)
{renderElement ? (
renderElement(buttonProps)
) : (
<button type="button" role="tab" {...buttonProps}>
{label}
Expand Down

0 comments on commit b39e260

Please sign in to comment.