-
Notifications
You must be signed in to change notification settings - Fork 169
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-142935 [Project PEP] PEP <> Geo Routing Modal Interactions #2403
Changes from 1 commit
6ff3c98
2d0ee33
164037a
0cff0ae
50c63e3
99e4d1d
f1b4a5e
c2aadc2
c52ffa9
d73dbf8
d5fbaef
2ad215a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,16 @@ | |
return icons.company; | ||
}; | ||
|
||
const waitForClosedGRMThen = (loadPEP) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of polling the DOM, you should listen for milo:modal:closed on the window object. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem is that the global-navigation.js/webapp-prompt.js might not have loaded by the time the user gets rid of the GRM, especially on slow connections, so the event would be missed and we would have to poll anyway unless we set a global flag. I'm not sure this would be all that much more readable than what we have now. Is there a particular compunction we should have against polling for the GRM? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can check to see if .locale-modal-v2 is present in the DOM first and if it's available there, then add an event listening for it to close. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in general polling is worse for performance than just listening to the right event. |
||
const grExists = !!document.querySelector('.locale-modal-v2') | ||
|| !!document.querySelector('.locale-modal'); | ||
if (grExists) { | ||
setTimeout(() => waitForClosedGRMThen(loadPEP), 200); | ||
return; | ||
} | ||
loadPEP(); | ||
}; | ||
|
||
class AppPrompt { | ||
constructor({ promptPath, entName, parent, getAnchorState } = {}) { | ||
this.promptPath = promptPath; | ||
|
@@ -43,8 +53,8 @@ | |
this.getAnchorState = getAnchorState; | ||
this.id = this.promptPath.split('/').pop(); | ||
this.elements = {}; | ||
|
||
this.init(); | ||
if (getConfig().grmActive) waitForClosedGRMThen(this.init); | ||
else this.init(); | ||
} | ||
|
||
init = async () => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -940,7 +940,7 @@ async function loadPostLCP(config) { | |
const georouting = getMetadata('georouting') || config.geoRouting; | ||
if (georouting === 'on') { | ||
const { default: loadGeoRouting } = await import('../features/georoutingv2/georoutingv2.js'); | ||
await loadGeoRouting(config, createTag, getMetadata, loadBlock, loadStyle); | ||
config.grmActive = await loadGeoRouting(config, createTag, getMetadata, loadBlock, loadStyle); | ||
sharmrj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you don't need to make all these changes to the georouting files. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually in retrospect I don't even think you need to have any code here. Just add that listener I described in your webapp-prompt file, no? |
||
if (config.mep?.targetEnabled === 'gnav') { | ||
await loadMartech({ persEnabled: true, postLCP: 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.
all these changes are unnecessary