From 2b36860c45f65234917a1e06244cfe1a0d13df6e Mon Sep 17 00:00:00 2001 From: Caleb Cox Date: Mon, 13 Jan 2025 15:41:42 -0600 Subject: [PATCH] Fix size logic --- .../registerAccountModal.component.js | 8 +++--- .../registerAccountModal.component.spec.js | 26 ++++++++++++------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/common/components/registerAccountModal/registerAccountModal.component.js b/src/common/components/registerAccountModal/registerAccountModal.component.js index c4457e77c..ca5d132b5 100644 --- a/src/common/components/registerAccountModal/registerAccountModal.component.js +++ b/src/common/components/registerAccountModal/registerAccountModal.component.js @@ -148,11 +148,9 @@ class RegisterAccountModalController { stateChanged (state) { this.element.dataset.state = state - if (this.welcomeBack && state === 'sign-in') { - // Use a medium (instead of small) modal for sign in models when they show the welcome back message - this.setModalSize('md') - } else if (state === 'sign-in' || state === 'sign-up') { - // Use a small modal for sign in modals without the welcome back message and sign up modals + if ((!this.welcomeBack && state === 'sign-in') || state === 'sign-up') { + // Use a small modal for sign in modals without a welcome back message and for sign up modals + // regardless of the screen size because they can't take advantage of the extra width this.setModalSize('sm') } else if (this.$window.innerWidth >= 1200) { // Use a large modal on wide screens for other modals diff --git a/src/common/components/registerAccountModal/registerAccountModal.component.spec.js b/src/common/components/registerAccountModal/registerAccountModal.component.spec.js index cdfb31450..fa9503f81 100644 --- a/src/common/components/registerAccountModal/registerAccountModal.component.spec.js +++ b/src/common/components/registerAccountModal/registerAccountModal.component.spec.js @@ -250,12 +250,20 @@ describe('registerAccountModal', function () { }) describe('stateChanged( state )', () => { + let originalWidth + beforeEach(() => { + originalWidth = $ctrl.$window.innerWidth + $ctrl.state = 'unknown' jest.spyOn($ctrl, 'setModalSize').mockImplementation(() => {}) jest.spyOn($ctrl, 'scrollModalToTop').mockImplementation(() => {}) }) + afterEach(() => { + $ctrl.$window.innerWidth = originalWidth + }) + it('should scroll to the top of the modal', () => { $ctrl.stateChanged() @@ -299,10 +307,17 @@ describe('registerAccountModal', function () { $ctrl.welcomeBack = true }) - it('sets the sign-in modal size to medium', () => { + it('sets the sign-in modal size to large on wide screens', () => { + $ctrl.$window.innerWidth = 1200 $ctrl.stateChanged('sign-in') - expect($ctrl.setModalSize).toHaveBeenCalledWith('md') + expect($ctrl.setModalSize).toHaveBeenCalledWith('lg') + }) + + it('sets the sign-in modal size to small on narrow screens', () => { + $ctrl.stateChanged('sign-in') + + expect($ctrl.setModalSize).toHaveBeenCalledWith('sm') }) it('sets the sign-up modal size to small', () => { @@ -319,17 +334,10 @@ describe('registerAccountModal', function () { }) describe('when the screen is wide', () => { - let originalWidth - beforeEach(() => { - originalWidth = $ctrl.$window.innerWidth $ctrl.$window.innerWidth = 1200 }) - afterEach(() => { - $ctrl.$window.innerWidth = originalWidth - }) - it('sets the sign-in modal size to small', () => { $ctrl.stateChanged('sign-in')