diff --git a/common/templates/xblock_v2/xblock_iframe.html b/common/templates/xblock_v2/xblock_iframe.html index 5e3aac965e2..07d81b962a6 100644 --- a/common/templates/xblock_v2/xblock_iframe.html +++ b/common/templates/xblock_v2/xblock_iframe.html @@ -270,14 +270,22 @@ } if ('{{ view_name | safe }}' === 'studio_view') { - // Used when rendering the `studio_view`, in order to intercept and handle the cancel button event - document.querySelector('.cancel-button').addEventListener('click', function() { - event.preventDefault(); - window.parent.postMessage({ - type: 'xblock-event', - eventName: 'cancel-clicked', - }, '*'); - }); + // Used when rendering the `studio_view`, in order to avoid open a new tab on click cancel or save + const selectors = [ + '.cancel-button', + '.save-button', + '.action-cancel', + '.action-save', + ]; + + for (const selector of selectors) { + const queryObject = document.querySelector(selector); + if (queryObject) { + queryObject.addEventListener('click', function() { + event.preventDefault(); + }); + } + } } }