diff --git a/apps/portal/src/components/pages/OfferPage.js b/apps/portal/src/components/pages/OfferPage.js
index f1863d2581..2b2de7657b 100644
--- a/apps/portal/src/components/pages/OfferPage.js
+++ b/apps/portal/src/components/pages/OfferPage.js
@@ -6,6 +6,7 @@ import CloseButton from '../common/CloseButton';
import InputForm from '../common/InputForm';
import {getCurrencySymbol, getProductFromId, hasMultipleProductsFeature, isSameCurrency, formatNumber, hasMultipleNewsletters} from '../../utils/helpers';
import {ValidateInputForm} from '../../utils/form';
+import {interceptAnchorClicks} from '../../utils/links';
import NewsletterSelectionPage from './NewsletterSelectionPage';
export const OfferPageStyles = () => {
@@ -252,13 +253,6 @@ export default class OfferPage extends React.Component {
const className = `gh-portal-signup-terms ${errorClassName}`;
- const interceptAnchorClicks = (e) => {
- if (e.target.tagName === 'A') {
- e.preventDefault();
- window.open(e.target.href, '_blank');
- }
- };
-
return (
{signupTerms}
diff --git a/apps/portal/src/components/pages/SignupPage.js b/apps/portal/src/components/pages/SignupPage.js
index d48fd74c2e..e8fb343360 100644
--- a/apps/portal/src/components/pages/SignupPage.js
+++ b/apps/portal/src/components/pages/SignupPage.js
@@ -9,6 +9,7 @@ import InputForm from '../common/InputForm';
import {ValidateInputForm} from '../../utils/form';
import {getSiteProducts, getSitePrices, hasOnlyFreePlan, isInviteOnlySite, freeHasBenefitsOrDescription, hasOnlyFreeProduct, getFreeProductBenefits, getFreeTierDescription, hasMultipleNewsletters, hasFreeTrialTier, isSignupAllowed} from '../../utils/helpers';
import {ReactComponent as InvitationIcon} from '../../images/icons/invitation.svg';
+import {interceptAnchorClicks} from '../../utils/links';
export const SignupPageStyles = `
.gh-portal-back-sitetitle {
@@ -530,13 +531,6 @@ class SignupPage extends React.Component {
const className = `gh-portal-signup-terms ${errorClassName}`;
- const interceptAnchorClicks = (e) => {
- if (e.target.tagName === 'A') {
- e.preventDefault();
- window.open(e.target.href, '_blank');
- }
- };
-
return (
{signupTerms}
diff --git a/apps/portal/src/utils/links.js b/apps/portal/src/utils/links.js
new file mode 100644
index 0000000000..d31e9f6fc5
--- /dev/null
+++ b/apps/portal/src/utils/links.js
@@ -0,0 +1,10 @@
+export const interceptAnchorClicks = (e) => {
+ if (e.currentTarget.contains(e.target)) {
+ const anchor = e.target.closest('a');
+
+ if (anchor) {
+ e.preventDefault();
+ window.open(anchor.href, '_blank');
+ }
+ }
+};