diff --git a/__tests__/index.test.tsx b/__tests__/index.test.tsx
index a4e87102..4f1a0b10 100644
--- a/__tests__/index.test.tsx
+++ b/__tests__/index.test.tsx
@@ -169,6 +169,62 @@ describe('modal', () => {
unmount();
expect(document.documentElement.style.position).toBe('');
});
+
+ it('should unblock scroll when multiple modals are opened and then closed', async () => {
+ const { rerender, getAllByTestId, queryByText } = render(
+
+ null}>
+ first modal
+
+ null}>
+ second modal
+
+
+ );
+ expect(document.documentElement.style.position).toBe('fixed');
+
+ // We close one modal, the scroll should be locked
+ rerender(
+
+ null}>
+ first modal
+
+ null}>
+ second modal
+
+
+ );
+
+ fireEvent.animationEnd(getAllByTestId('overlay')[1]);
+ await waitFor(
+ () => {
+ expect(queryByText(/second modal/)).not.toBeInTheDocument();
+ },
+ { timeout: 10 }
+ );
+ expect(document.documentElement.style.position).toBe('fixed');
+
+ // We close the second modal, the scroll should be unlocked
+ rerender(
+
+ null}>
+ first modal
+
+ null}>
+ second modal
+
+
+ );
+
+ fireEvent.animationEnd(getAllByTestId('overlay')[0]);
+ await waitFor(
+ () => {
+ expect(queryByText(/first modal/)).not.toBeInTheDocument();
+ },
+ { timeout: 10 }
+ );
+ expect(document.documentElement.style.position).toBe('');
+ });
});
describe('closeIcon', () => {