diff --git a/packages/bpk-scrim-utils/src/withScrim-test.tsx b/packages/bpk-scrim-utils/src/withScrim-test.tsx index 3dc8fadf3d..04e21d89dc 100644 --- a/packages/bpk-scrim-utils/src/withScrim-test.tsx +++ b/packages/bpk-scrim-utils/src/withScrim-test.tsx @@ -52,6 +52,9 @@ jest.mock('./scroll-utils', () => ({ unfixBody: jest.fn(), })); +beforeEach(() => { + jest.resetAllMocks(); +}); describe('BpkScrim', () => { describe('render', () => { let TestComponent: ComponentType | string; @@ -153,6 +156,8 @@ describe('BpkScrim', () => { ); expect(lockScroll).toHaveBeenCalled(); expect(focusStore.storeFocus).toHaveBeenCalled(); + expect(storeScroll).not.toHaveBeenCalled(); + expect(fixBody).not.toHaveBeenCalled(); expect(mockSetAttribute).toHaveBeenCalledWith('aria-hidden', 'true'); }); }); @@ -207,6 +212,8 @@ describe('BpkScrim', () => { unmount(); expect(unlockScroll).toHaveBeenCalled(); + expect(restoreScroll).not.toHaveBeenCalled(); + expect(unfixBody).not.toHaveBeenCalled(); expect(focusStore.storeFocus).toHaveBeenCalled(); expect(focusScope.unscopeFocus).toHaveBeenCalled(); expect(mockRemoveAttribute).toHaveBeenCalledWith('aria-hidden'); diff --git a/packages/bpk-scrim-utils/src/withScrim.tsx b/packages/bpk-scrim-utils/src/withScrim.tsx index 8cd170c5d3..1d3f5622a8 100644 --- a/packages/bpk-scrim-utils/src/withScrim.tsx +++ b/packages/bpk-scrim-utils/src/withScrim.tsx @@ -90,9 +90,14 @@ const withScrim =

( */ if (isIphone || isIpad) { storeScroll(); - lockScroll(); fixBody(); } + /** + * lockScroll and the associated unlockScroll is how we control the scroll behaviour of the application when the scrim is active. + * The desired behaviour is to prevent the user from scrolling content behind the scrim. The above iOS fixes are in place because lockScroll alone does not solve due to iOS specific issues. + */ + + lockScroll(); if (applicationElement) { applicationElement.setAttribute('aria-hidden', 'true'); @@ -109,9 +114,9 @@ const withScrim =

( if (isIphone || isIpad) { setTimeout(restoreScroll, 0); - unlockScroll(); unfixBody(); } + unlockScroll(); if (applicationElement) { applicationElement.removeAttribute('aria-hidden');