diff --git a/test/core/workflow/workflow-acrobat/action-binder.test.js b/test/core/workflow/workflow-acrobat/action-binder.test.js index 534ca68f9..c58c7bff1 100644 --- a/test/core/workflow/workflow-acrobat/action-binder.test.js +++ b/test/core/workflow/workflow-acrobat/action-binder.test.js @@ -1614,11 +1614,14 @@ describe('ActionBinder', () => { splashScreenEl: splashLayer, LOADER_LIMIT: 95, clearProgressBarHandler: sinon.stub(), + toggleCancelButton: sinon.stub(), updateProgressBar: sinon.stub(), showSplashScreen: sinon.stub().resolves(), }; actionBinder.transitionScreen = existingTransitionScreen; await actionBinder.continueInApp(); + expect(existingTransitionScreen.toggleCancelButton.calledOnceWith(false)).to.be.true; + expect(existingTransitionScreen.toggleCancelButton.calledBefore(existingTransitionScreen.updateProgressBar)).to.be.true; expect(actionBinder.transitionScreen).to.equal(existingTransitionScreen); expect(actionBinder.LOADER_LIMIT).to.equal(100); expect(existingTransitionScreen.LOADER_LIMIT).to.equal(100); diff --git a/test/unitylibs/scripts/transition-screen.test.js b/test/unitylibs/scripts/transition-screen.test.js index 3c47bbc74..58cd2e8c4 100644 --- a/test/unitylibs/scripts/transition-screen.test.js +++ b/test/unitylibs/scripts/transition-screen.test.js @@ -160,6 +160,21 @@ describe('TransitionScreen', () => { }); }); + describe('toggleCancelButton', () => { + it('should hide and re-show the cancel button', () => { + splashScreenEl.innerHTML = 'Cancel'; + const cancelBtn = splashScreenEl.querySelector('a.con-button'); + screen.toggleCancelButton(false); + expect(cancelBtn.style.display).to.equal('none'); + screen.toggleCancelButton(true); + expect(cancelBtn.style.display).to.equal(''); + }); + + it('should not throw when there is no cancel button', () => { + expect(() => screen.toggleCancelButton(false)).to.not.throw(); + }); + }); + describe('splashVisibilityController', () => { beforeEach(() => { const parent = document.createElement('div'); @@ -193,6 +208,18 @@ describe('TransitionScreen', () => { expect(document.querySelector('main').getAttribute('aria-hidden')).to.equal('true'); stub.restore(); }); + it('should restore a hidden cancel button when the splash is shown or hidden', () => { + const stub = sinon.stub(screen, 'progressBarHandler'); + splashScreenEl.innerHTML = 'Cancel'; + const cancelBtn = splashScreenEl.querySelector('a.con-button'); + screen.toggleCancelButton(false); + screen.splashVisibilityController(true); + expect(cancelBtn.style.display).to.equal(''); + screen.toggleCancelButton(false); + screen.splashVisibilityController(false); + expect(cancelBtn.style.display).to.equal(''); + stub.restore(); + }); }); describe('updateCopyForDevice', () => { diff --git a/unitylibs/core/workflow/workflow-acrobat/action-binder.js b/unitylibs/core/workflow/workflow-acrobat/action-binder.js index 71b4d9e57..266031cdd 100644 --- a/unitylibs/core/workflow/workflow-acrobat/action-binder.js +++ b/unitylibs/core/workflow/workflow-acrobat/action-binder.js @@ -801,6 +801,8 @@ export default class ActionBinder { this.LOADER_LIMIT = 100; this.transitionScreen.LOADER_LIMIT = 100; this.transitionScreen.clearProgressBarHandler(); + // Redirect is committed from here on; Cancel can no longer stop it, so hide it (per design). + this.transitionScreen.toggleCancelButton(false); const splashLayer = this.transitionScreen.splashScreenEl; if (this.isDirectUploadVerb(this.filesData?.size)) await this.runProgressBarUpdate(splashLayer); else this.transitionScreen.updateProgressBar(splashLayer, 100); diff --git a/unitylibs/scripts/transition-screen.js b/unitylibs/scripts/transition-screen.js index 7abc79127..ce816daf3 100644 --- a/unitylibs/scripts/transition-screen.js +++ b/unitylibs/scripts/transition-screen.js @@ -223,6 +223,11 @@ export default class TransitionScreen { this.initActionListeners(this.splashScreenEl, actMap); } + toggleCancelButton(visible) { + const cancelBtn = this.splashScreenEl?.querySelector('a.con-button[href*="#_cancel"]'); + if (cancelBtn) cancelBtn.style.display = visible ? '' : 'none'; + } + resetSplashVideos() { if (!this.splashScreenEl) return; const videos = this.splashScreenEl.querySelectorAll('video'); @@ -239,6 +244,7 @@ export default class TransitionScreen { } splashVisibilityController(displayOn) { + this.toggleCancelButton(true); if (!displayOn) { this.clearProgressBarHandler(); this.LOADER_LIMIT = 95;