-
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-142935 [Project PEP] PEP <> Geo Routing Modal Interactions #2403
Changes from all commits
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 @@ const getIcon = (content) => { | |
return icons.company; | ||
}; | ||
|
||
const modalsActive = () => !!document.querySelector('.dialog-modal'); | ||
|
||
const waitForClosedModalsThen = (loadPEP) => { | ||
if (modalsActive()) { | ||
setTimeout(() => waitForClosedModalsThen(loadPEP), 200); | ||
return; | ||
} | ||
loadPEP(); | ||
}; | ||
|
||
class AppPrompt { | ||
constructor({ promptPath, entName, parent, getAnchorState } = {}) { | ||
this.promptPath = promptPath; | ||
|
@@ -43,8 +53,13 @@ class AppPrompt { | |
this.getAnchorState = getAnchorState; | ||
this.id = this.promptPath.split('/').pop(); | ||
this.elements = {}; | ||
|
||
this.init(); | ||
if (modalsActive()) { | ||
window.addEventListener( | ||
'milo:modal:closed', | ||
() => waitForClosedModalsThen(this.init), | ||
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. Could we not add 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. I like to be explicit about what I'm passing to functions, and I like the CPS-ish semantics of writing "do an action and then do this - " by explicitly passing the function (so long as we aren't doing long chains of it, of course). Though if you think the |
||
{ once: true }, | ||
); | ||
} else this.init(); | ||
} | ||
|
||
init = async () => { | ||
|
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.
Could we not use a
setInterval
to avoid the recursive calls?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'd prefer to not use setInterval since we'd have to keep track of the
setInterval
ID and clean it up after withclearInterval
. AndwaitForClosedModalsThen
isn't recursive in the sense that it's growing the callstack indefinitely, it, likesetInterval
, adds a function to the task queue, and in that sense is (to us, at least) indistinguishable in behavior fromsetInterval
. The question is of whether we prefer the extra code to clean up the interval or the extra code for adding to the event queue.