From f402ca80a2218cc9c34ee7b92ab490d7cf38843e Mon Sep 17 00:00:00 2001 From: Andrew Nelson Date: Fri, 9 Feb 2024 13:30:59 -0800 Subject: [PATCH 1/2] moved inline style to class, fixed import --- src/components/Modal/Modal.module.scss | 5 +++++ src/components/Modal/utils.test.ts | 2 +- src/components/Modal/utils.ts | 7 ++----- 3 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 src/components/Modal/Modal.module.scss diff --git a/src/components/Modal/Modal.module.scss b/src/components/Modal/Modal.module.scss new file mode 100644 index 0000000000..78e6313a12 --- /dev/null +++ b/src/components/Modal/Modal.module.scss @@ -0,0 +1,5 @@ +.outer { + overflow: scroll; + -ms-overflow-style: scrollbar; + visibility: hidden; +} diff --git a/src/components/Modal/utils.test.ts b/src/components/Modal/utils.test.ts index ce2d14b088..bb99f6318d 100644 --- a/src/components/Modal/utils.test.ts +++ b/src/components/Modal/utils.test.ts @@ -1,4 +1,4 @@ -import { renderHook, act } from '@testing-library/react' +import { renderHook, act } from '@testing-library/react-hooks' import { useModal } from './utils' diff --git a/src/components/Modal/utils.ts b/src/components/Modal/utils.ts index 905f46324f..8a76238468 100644 --- a/src/components/Modal/utils.ts +++ b/src/components/Modal/utils.ts @@ -1,4 +1,5 @@ import React, { useState } from 'react' +import styles from './Modal.module.scss' export type ModalHook = { isOpen: boolean @@ -48,11 +49,7 @@ export const getScrollbarWidth = (): string => { // Only run in browser if (typeof document !== 'undefined') { const outer = document.createElement('div') - - outer.setAttribute( - 'style', - 'visibility: hidden; overflow: scroll; ms-overflow-style: scrollbar' - ) + outer.className = styles.outer document.body.appendChild(outer) From 88d8b761937c90ef197ca44c9e73edcc5086af6c Mon Sep 17 00:00:00 2001 From: Andrew Nelson Date: Mon, 12 Feb 2024 22:53:31 -0800 Subject: [PATCH 2/2] reset 'fix' --- src/components/Modal/utils.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Modal/utils.test.ts b/src/components/Modal/utils.test.ts index bb99f6318d..ce2d14b088 100644 --- a/src/components/Modal/utils.test.ts +++ b/src/components/Modal/utils.test.ts @@ -1,4 +1,4 @@ -import { renderHook, act } from '@testing-library/react-hooks' +import { renderHook, act } from '@testing-library/react' import { useModal } from './utils'