Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
Update onClick prop name
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Tran authored and Andrew Tran committed Oct 9, 2023
1 parent 3cddf3d commit 132963b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions packages/terra-clinical-header/src/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ const propTypes = {

/**
* Callback function triggered via hyperlink button title.
* Sets the header title to be a hyperlink.
*/
onTextClick: PropTypes.func,
onClick: PropTypes.func,
};

const defaultProps = {
Expand All @@ -85,7 +86,7 @@ const Header = ({
level,
id,
isSubheader,
onTextClick,
onClick,
...customProps
}) => {
const theme = useContext(ThemeContext);
Expand All @@ -107,8 +108,8 @@ const Header = ({
titleElement = (
<div className={cx('title-container')}>
<HeaderElement id={id} className={cx('title')}>
{onTextClick ? (
<Hyperlink onClick={onTextClick} text={titleContent} />
{onClick ? (
<Hyperlink onClick={onClick} text={titleContent} />
) : (
titleContent
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Header from 'terra-clinical-header';

const HyperlinkTitleHeader = () => (
// eslint-disable-next-line no-console
<Header onTextClick={() => { console.log('Hyperlink title clicked'); }} text="John Smith" level={3} />
<Header onClick={() => { console.log('Hyperlink title clicked'); }} text="John Smith" level={3} />
);

export default HyperlinkTitleHeader;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import Header from '../../../Header';

const HyperlinkTitleHeader = () => (
<Header onTextClick={() => {}} text="John Smith" />
<Header onClick={() => {}} text="John Smith" />
);

export default HyperlinkTitleHeader;
2 changes: 1 addition & 1 deletion packages/terra-clinical-header/tests/jest/Header.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ it('should render a header with default heading level when level not set', () =>
});

it('should render a header with hyperlink title', () => {
const header = shallowWithIntl(<Header onTextClick={mockFunc} text="Title" />);
const header = shallowWithIntl(<Header onClick={mockFunc} text="Title" />);

expect(header.find('h1').length).toEqual(1);
const hyperlinkButton = header.find('InjectIntl(Hyperlink)');
Expand Down

0 comments on commit 132963b

Please sign in to comment.