Skip to content

Commit cd4aa35

Browse files
committed
[FIXED] : Scroll Issue
1 parent 3274903 commit cd4aa35

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

components/Sidebar.tsx

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -175,21 +175,34 @@ export const SidebarLayout = ({ children }: { children: React.ReactNode }) => {
175175
const handleRotate = () => setRotateChevron(!rotateChevron);
176176
const rotate = rotateChevron ? 'rotate(180deg)' : 'rotate(0)';
177177
const pathWtihoutFragment = extractPathWithoutFragment(router.asPath);
178+
178179
useEffect(() => {
179-
if (window) {
180+
if (typeof window !== 'undefined') {
181+
if (open) {
182+
document.body.style.overflow = 'hidden';
183+
} else {
184+
document.body.style.overflow = 'unset';
185+
}
186+
180187
window.addEventListener('resize', () => {
181188
if (window.innerWidth > 1024) {
182189
setOpen(false);
190+
document.body.style.overflow = 'unset';
183191
}
184192
});
193+
194+
return () => {
195+
document.body.style.overflow = 'unset';
196+
};
185197
}
186-
}, [typeof window !== 'undefined']);
198+
}, [open]);
199+
187200
return (
188201
<div className='max-w-[1400px] mx-auto flex flex-col items-center'>
189-
<section>
190-
<div className='bg-primary dark:bg-slate-900 w-full h-12 mt-[4.5rem] z-150 flex relative flex-col justify-center items-center lg:hidden '>
202+
<section className='w-full'>
203+
<div className='bg-primary dark:bg-slate-900 w-full h-12 fixed top-[4.5rem] z-[160] flex flex-col justify-center items-center lg:hidden '>
191204
<div
192-
className='z-[150] flex w-full bg-primary dark:bg-slate-900 justify-between items-center'
205+
className='z-[160] flex w-full bg-primary dark:bg-slate-900 justify-between items-center'
193206
onMouseDown={(e) => e.stopPropagation()}
194207
onClick={(e) => {
195208
e.stopPropagation();
@@ -235,16 +248,18 @@ export const SidebarLayout = ({ children }: { children: React.ReactNode }) => {
235248
</div>
236249
</div>
237250

251+
<div className='h-12 mt-[4.5rem] lg:hidden'></div>
252+
238253
<div
239-
className={`z-[150] absolute top-10 mt-24 left-0 h-full w-screen bg-white dark:bg-slate-900 dark:shadow-lg transform ${open ? '-translate-x-0' : '-translate-x-full'} transition-transform duration-300 ease-in-out filter drop-shadow-md `}
254+
className={`z-[150] fixed top-[calc(4.5rem+3rem)] left-0 h-[calc(100vh-4.5rem-3rem)] w-screen bg-white dark:bg-slate-900 dark:shadow-lg transform ${open ? 'translate-x-0' : '-translate-x-full'} transition-transform duration-300 ease-in-out filter drop-shadow-md overflow-y-auto pt-4`}
240255
>
241-
<div className='flex flex-col dark:bg-slate-900'>
256+
<div className='flex flex-col bg-white dark:bg-slate-900 min-h-full'>
242257
<DocsNav open={open} setOpen={setOpen} />
243258
</div>
244259
</div>
245-
<div className='dark:bg-slate-800 max-w-[1400px] grid grid-cols-1 lg:grid-cols-4 mx-4 md:mx-12'>
260+
<div className='dark:bg-slate-800 max-w-[1400px] grid grid-cols-1 lg:grid-cols-4 mx-4 md:mx-12 lg:pt-0 -mt-8'>
246261
<div className='hidden lg:block mt-24 sticky top-24 h-[calc(100vh-6rem)] overflow-hidden'>
247-
<div className='h-full overflow-y-auto scrollbar-hidden'>
262+
<div className='h-full bg-white scrollbar-hidden'>
248263
<DocsNav open={open} setOpen={setOpen} />
249264
<CarbonAds
250265
className='lg:mt-8 w-4/5 mx-auto lg:ml-4'
@@ -268,7 +283,6 @@ export const DocsNav = ({
268283
setOpen: (open: boolean) => void;
269284
}) => {
270285
const router = useRouter();
271-
272286
/* eslint-disable no-constant-condition */
273287
const [active, setActive] = useState({
274288
getDocs: false,

0 commit comments

Comments
 (0)