Skip to content

Commit

Permalink
MWPW-157761: Tab preselect in external modals [catalog] (#2828)
Browse files Browse the repository at this point in the history
  • Loading branch information
Axelcureno authored Sep 4, 2024
1 parent 501f559 commit 8956fbe
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions libs/blocks/merch/merch.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,14 +364,16 @@ async function openExternalModal(url, getModal) {
});
}

const isInternalModal = (url) => /\/fragments\//.test(url);

export async function openModal(e, url, offerType) {
e.preventDefault();
e.stopImmediatePropagation();
const { getModal } = await import('../modal/modal.js');
await import('../modal/modal.merch.js');
const offerTypeClass = offerType === OFFER_TYPE_TRIAL ? 'twp' : 'crm';
let modal;
if (/\/fragments\//.test(url)) {
if (isInternalModal(url)) {
const fragmentPath = url.split(/hlx.(page|live)/).pop();
modal = await openFragmentModal(fragmentPath, getModal);
} else {
Expand All @@ -398,7 +400,8 @@ export async function getModalAction(offers, options) {
const columnName = (offerType === OFFER_TYPE_TRIAL) ? FREE_TRIAL_PATH : BUY_NOW_PATH;
let url = checkoutLinkConfig[columnName];
if (!url) return undefined;
url = localizeLink(checkoutLinkConfig[columnName]);
url = isInternalModal(url)
? localizeLink(checkoutLinkConfig[columnName]) : checkoutLinkConfig[columnName];
return { url, handler: (e) => openModal(e, url, offerType) };
}

Expand Down

0 comments on commit 8956fbe

Please sign in to comment.