Skip to content

Commit

Permalink
refactor!: remove the long-deprecated Hyperlink.content prop
Browse files Browse the repository at this point in the history
  • Loading branch information
bradenmacdonald committed May 17, 2024
1 parent 2d79395 commit bd92ad3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
14 changes: 0 additions & 14 deletions src/Hyperlink/Hyperlink.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,6 @@ describe('correct rendering', () => {
beforeEach(() => {
onClick.mockClear();
});
it('renders with deprecated "content" prop', async () => {
// @ts-expect-error - we don't include 'content' in the types since it's deprecated. Change to 'children'.
const { getByRole } = render(<Hyperlink {...props} content={content} />);
const wrapper = getByRole('link');
expect(wrapper).toBeInTheDocument();

expect(wrapper).toHaveClass('pgn__hyperlink');
expect(wrapper).toHaveTextContent('content');
expect(wrapper).toHaveAttribute('href', destination);
expect(wrapper).toHaveAttribute('target', '_self');

await userEvent.click(wrapper);
expect(onClick).toHaveBeenCalledTimes(1);
});

it('renders Hyperlink', async () => {
const { getByRole } = render(<Hyperlink {...props}>{content}</Hyperlink>);
Expand Down
12 changes: 3 additions & 9 deletions src/Hyperlink/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import classNames from 'classnames';
import { Launch } from '../../icons';
import Icon from '../Icon';

import withDeprecatedProps, { DeprTypes } from '../withDeprecatedProps';

export const HYPER_LINK_EXTERNAL_LINK_ALT_TEXT = 'in a new tab';
export const HYPER_LINK_EXTERNAL_LINK_TITLE = 'Opens in a new tab';

Expand All @@ -28,6 +26,8 @@ interface Props extends Omit<React.ComponentPropsWithoutRef<'a'>, 'href' | 'targ
/** specify if we need to show launch Icon. By default, it will be visible. */
showLaunchIcon?: boolean;
target?: '_blank' | '_self';
/** @deprecated since Paragon v4.0.2. Use children instead. */
content?: never;
}

const Hyperlink = React.forwardRef<HTMLAnchorElement, Props>(({
Expand Down Expand Up @@ -130,10 +130,4 @@ Hyperlink.propTypes = {
showLaunchIcon: PropTypes.bool,
};

export default withDeprecatedProps(Hyperlink, 'Hyperlink', {
/** specifies the text or element that a URL should be associated with */
content: {
deprType: DeprTypes.MOVED,
newName: 'children',
},
});
export default Hyperlink;

0 comments on commit bd92ad3

Please sign in to comment.