From 5d7317ca10b91a455ae286862ed3f27455541b45 Mon Sep 17 00:00:00 2001 From: Naveen <54985099+naveen8801@users.noreply.github.com> Date: Fri, 19 Jul 2024 17:00:10 +0530 Subject: [PATCH] fix(Button): noreferrer in rel attribute of button rendered as link (#2308) * Removed: defaultRel var from BaseButton.tsx * Update src/components/Button/Button/__tests__/Button.web.test.tsx * Create changeset-xyz.md --------- Co-authored-by: Saurabh Daware --- .changeset/changeset-xyz.md | 9 +++++++++ .../src/components/Button/BaseButton/BaseButton.tsx | 3 +-- .../Button/Button/__tests__/Button.web.test.tsx | 2 +- .../__tests__/__snapshots__/Button.ssr.test.tsx.snap | 3 +-- 4 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 .changeset/changeset-xyz.md diff --git a/.changeset/changeset-xyz.md b/.changeset/changeset-xyz.md new file mode 100644 index 00000000000..5a3c453d1cc --- /dev/null +++ b/.changeset/changeset-xyz.md @@ -0,0 +1,9 @@ +--- +"@razorpay/blade": patch +--- + +fix: remove default `rel` values + +> [!NOTE] +> +> While its non-ui-breaking change, you might want to add `rel="noopener noreferrer"` to your Button if that is what you're expecting. This PR removes the defaults in-order to not break analytics that relies on referrer. diff --git a/packages/blade/src/components/Button/BaseButton/BaseButton.tsx b/packages/blade/src/components/Button/BaseButton/BaseButton.tsx index d93f89ab9bd..f1285723012 100644 --- a/packages/blade/src/components/Button/BaseButton/BaseButton.tsx +++ b/packages/blade/src/components/Button/BaseButton/BaseButton.tsx @@ -396,7 +396,6 @@ const _BaseButton: React.ForwardRefRenderFunction getRenderElement(href), [href]); - const defaultRel = target === '_blank' ? 'noreferrer noopener' : undefined; const defaultRole = isLink ? 'link' : 'button'; const handlePointerPressedIn = React.useCallback(() => { @@ -438,7 +437,7 @@ const _BaseButton: React.ForwardRefRenderFunction', () => { it('should render button as link', () => { const { getByRole } = renderWithTheme( - , ); diff --git a/packages/blade/src/components/Button/Button/__tests__/__snapshots__/Button.ssr.test.tsx.snap b/packages/blade/src/components/Button/Button/__tests__/__snapshots__/Button.ssr.test.tsx.snap index d4746dfac47..b26696c5e39 100644 --- a/packages/blade/src/components/Button/Button/__tests__/__snapshots__/Button.ssr.test.tsx.snap +++ b/packages/blade/src/components/Button/Button/__tests__/__snapshots__/Button.ssr.test.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`