-
Notifications
You must be signed in to change notification settings - Fork 174
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-140481: Delayed modal #1877
Conversation
@@ -99,18 +99,105 @@ export const preloadManifests = ({ targetManifests = [], persManifests = [] }) = | |||
|
|||
export const getFileName = (path) => path?.split('/').pop(); | |||
|
|||
const createFrag = (el, url, manifestId) => { | |||
let href = url; | |||
export async function initDelayedModal({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think modal logic should go in modal.js
if (!window.sessionStorage.getItem('wasDelayedModalShown')) { | ||
setTimeout(() => { | ||
getModal(details); | ||
window.sessionStorage.setItem('wasDelayedModalShown', true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this implementation supports one single delayed modal.
if the user navigates from one page to another in the same session, I think the other modals will not be shown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test doesn't cover oncePerSession option.
please use oncePerSession, and link one page to the other one and try to navigate.
I expect the second modal will not be shown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yesil
I cross-linked both pages, set the display
param to session
, and it works as expected:
- When I open the first page for the first time, the modal is shown, and the the
wasDelayedModalShown
key is saved in the session storage; - Then I click the link to navigate to the second page, and the modal is not shown, which is expected as the modal should be shown once per browser session and it was already shown on the first page.
- Other modals which I linked to both pages get opened on click.
I will ask Reuben to verify this as well.
I also refactored the code a bit to make it simpler, could you please review once again?
}); | ||
|
||
it('creates and opens the delayed modal', async () => { | ||
const hash = '#delayed-modal'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delayed-modal
shounds to technical.
I wonder if we could adopt a more short/cryptic naming here, like md
or dm
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be simpler.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1877 +/- ##
==========================================
+ Coverage 95.64% 95.68% +0.04%
==========================================
Files 159 159
Lines 41183 41345 +162
==========================================
+ Hits 39388 39562 +174
+ Misses 1795 1783 -12 ☔ View full report in Codecov by Sentry. |
@auniverseaway |
46631ba
to
e4dfe62
Compare
eebf905
to
80e56ec
Compare
c0c5740
to
c11d4e8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't had a chance for an in-depth review but wanted to ask - why are all the changes in personalization needed?
Also we don't want personalization.js to load any external files (modal.js) unless absolutely needed.
I think that all of the modal logic needs to be in modal.js and should not require MEP in any way.
My thoughts:
With these changes, there are no changes needed to MEP. The fragment link set in the manifest would contain the info and modal.js would handle everything else. More minor thoughts:
Implementation details:
|
@mirafedas few observations adding here: plz review
2 Click event outside the modal has web interaction name 'modalClose:buttonClose' |
…das/milo into MWPW-140481-delayed-modal
Closing this PR as these changes are not actual anymore, and opening a new one |
This feature enables the delayed display of a modal, primarily intended for promotional purposes.
When parsing the promotional manifest, if we encounter a rule labeled insertContentAfter containing a link with valid parameters for delay and display, we dynamically generate a hidden link within the specified selector. This link behaves conventionally, triggering a modal upon click. Following this setup, we introduce a delay of some number of seconds before unveiling the modal, simultaneously appending a modal hash to the browser's URL. If the modal is configured for a one-time session display (display="session"), we remember this in sessionStorage to prevent subsequent displays upon page reload.
Resolves: MWPW-140481
Authoring documentation
Test URLs:
First page
Second page
Feel free to change the
display
param to eitherpageload
orsession
in this file