Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MWPW-154098: Retain Modal param while traversing back from Commerce to Page #2781

Open
wants to merge 2 commits into
base: stage
Choose a base branch
from

Conversation

mirafedas
Copy link
Contributor

@mirafedas mirafedas commented Aug 23, 2024

When users open a modal by clicking a CTA on a merch card, navigate away, and then return, the modal needs to reopen automatically. However, this wasn't working because our catalog page uses custom modals without updating the URL hash. As a result, the URL doesn't retain information about the previously open modal.

To address this, this PR introduces URL hash management. We now add a hash to the URL whenever a modal is opened and remove it when the modal is closed. On page load, each CTA is assigned a unique hash. If the browser's URL contains the hash of a previously opened modal, we automatically trigger a click on the corresponding CTA to reopen the modal.

Resolves: MWPW-154098

Test URLs:

For PSI check: https://mwpw-154098-catalog-modal-hash--milo--mirafedas.hlx.live/docs/authoring/promotions/delayed-modal?martech=off&georouting=off&mep=off

Copy link
Contributor

aem-code-sync bot commented Aug 23, 2024

Copy link
Contributor

This PR has not been updated recently and will be closed in 7 days if no action is taken. Please ensure all checks are passing, https://github.com/orgs/adobecom/discussions/997 provides instructions. If the PR is ready to be merged, please mark it with the "Ready for Stage" label.

@github-actions github-actions bot added the Stale label Aug 31, 2024
Copy link

codecov bot commented Aug 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.31%. Comparing base (05ebf1f) to head (ce86bbd).
Report is 1 commits behind head on stage.

Additional details and impacted files
@@           Coverage Diff           @@
##            stage    #2781   +/-   ##
=======================================
  Coverage   96.30%   96.31%           
=======================================
  Files         242      242           
  Lines       54981    55019   +38     
=======================================
+ Hits        52950    52991   +41     
+ Misses       2031     2028    -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@3ch023 3ch023 removed the Stale label Sep 6, 2024
Copy link
Contributor

github-actions bot commented Sep 7, 2024

This pull request is not passing all required checks. Please see this discussion for information on how to get all checks passing. Inconsistent checks can be manually retried. If a test absolutely can not pass for a good reason, please add a comment with an explanation to the PR.

@mirafedas mirafedas added the run-nala Run Nala Test Automation against PR label Sep 10, 2024
libs/blocks/merch/merch.js Outdated Show resolved Hide resolved
const authoredHash = checkoutLinkConfig[`${(offerType === OFFER_TYPE_TRIAL) ? FREE_TRIAL_HASH : BUY_NOW_HASH}`];
const autogeneratedHash = `${offerType === 'TRIAL' ? 'try' : 'buy'}-${el.closest('merch-card')?.getAttribute('name')}`;
const hash = authoredHash ?? autogeneratedHash;
el.setAttribute('hash', hash);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hash it not a standard attribute, can you use data-modal-hash?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed to data-modal-hash to not mix it with other buttons that use data-modal-hash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-nala Run Nala Test Automation against PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants