MDL-68991 core: Prevent popup blockers blocking feedback window
Some browsers like Firefox are very inflexible with window.open() and block it if it is not instantly invoked after the user click. Also according to https://stackoverflow.com/a/6807615 it is best practice to replace self:: with static::
This commit is contained in:
@@ -42,8 +42,12 @@ export const registerEventListeners = () => {
|
||||
if (giveAction) {
|
||||
e.preventDefault();
|
||||
|
||||
giveFeedback()
|
||||
.then(() => hideRoot(giveAction))
|
||||
if (!window.open(giveAction.href)) {
|
||||
throw new Error('Unable to open popup');
|
||||
}
|
||||
|
||||
Promise.resolve(giveAction)
|
||||
.then(hideRoot)
|
||||
.then(recordAction)
|
||||
.catch(Notification.exception);
|
||||
}
|
||||
@@ -60,26 +64,6 @@ export const registerEventListeners = () => {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* The action function that is called when users choose to give feedback.
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
const giveFeedback = () => {
|
||||
return Ajax.call([{
|
||||
methodname: 'core_get_userfeedback_url',
|
||||
args: {
|
||||
contextid: M.cfg.contextid,
|
||||
}
|
||||
}])[0]
|
||||
.then(url => {
|
||||
if (!window.open(url)) {
|
||||
throw new Error('Unable to open popup');
|
||||
}
|
||||
return;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Record the action that the user took.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user