daisyui icon indicating copy to clipboard operation
daisyui copied to clipboard

Drawer that opens from right side of page (double scrollbar bug)

Open Gerwyn1 opened this issue 3 years ago β€’ 7 comments

drawer bug

This is the code I copied from the website:

<div class="drawer drawer-end">
  <input id="my-drawer-4" type="checkbox" class="drawer-toggle" />
  <div class="drawer-content">
    <!-- Page content here -->
    <label for="my-drawer-4" class="drawer-button btn btn-primary">Open drawer</label>
  </div> 
  <div class="drawer-side">
    <label for="my-drawer-4" class="drawer-overlay"></label>
    <ul class="menu p-4 overflow-y-auto w-80 bg-base-100 text-base-content">
      <!-- Sidebar content here -->
      <li><a>Sidebar Item 1</a></li>
      <li><a>Sidebar Item 2</a></li>
    </ul>
  </div>
</div>

I did exactly as told and inserted where my content should be (inside div with class of drawer-content ). the drawer works but i notice a scrollbar appeared and it belongs to the SAME div with the class of drawer-content. I tried every possible way to disable the scrollbar but to no avail. i could only hide it but the functionality still remains. i only want my main scrollbar (html).

Gerwyn1 avatar Aug 01 '22 12:08 Gerwyn1

I've had a look at the drawer and It seems to me that the <div className='drawer-content'> takes has h-screen but the button is pushing it down. and it takes more space creating the 2nd scrollbar.

Add a div with max-h-screen and wrap it around the drawer.

WickedInvi avatar Aug 06 '22 18:08 WickedInvi

Hi, try use this. Put this in your css file

/* Hide scrollbar for Chrome, Safari and Opera */
.drawer-side::-webkit-scrollbar {
    display: none;
}

nuradiba avatar Aug 08 '22 10:08 nuradiba

I could not reproduce this.
Here I only see 1 scroll bar and when the drawer sidebar opens, I only see the sidebar scrollbar:
https://play.tailwindcss.com/qDEqG17DUq

Can you share a sample repo?

saadeghi avatar Aug 12 '22 21:08 saadeghi

I'm dealing with the exact issue for some time now. At first I thought it's a bug within my setup than it exists on daistyUI official website. It might a safari thing (the browser I'm using). It's not about the display of the scroll bar but also the scroll lock.

https://user-images.githubusercontent.com/65782666/188478394-f662f8ce-2cf5-4be0-89f3-9570f892c8ae.mov

Tried to reproduce it in the play env but couldn't. @saadeghi I can invite you to the repo I'm facing the issue in

kkharji avatar Sep 05 '22 15:09 kkharji

Adding h-screen tailwindcss with h-screen seems to fix it. But the scroll lock is still there as with the official website.

kkharji avatar Sep 05 '22 17:09 kkharji

On safari I still have the issue of two scrolls. Stuff works well until I hit the bottom of the screen and then can't see the footer, in which case it gives me another scroll where if I scrolled, I no longer see the navbar

kkharji avatar Sep 06 '22 17:09 kkharji

Weird, but this same situation was happening to me. Since the <div className="drawer"> is already a wrapper. Nothing worked but giving that wrapper the absolute class to eliminate the double scrollbars.

iamhectorsosa avatar Dec 20 '22 12:12 iamhectorsosa

I have this issue too @ekqt s suggestion is the only one working for me , but we shouldnt have to use absolute

blowsie avatar Feb 04 '23 19:02 blowsie

onHide: () => {
    document.body.classList.remove('overflow-y-hidden')
},
onShow: () => {
    document.body.classList.add('overflow-y-hidden')
}

In code open / hide drawer

oxozle avatar Feb 07 '23 14:02 oxozle

I think this happens because you have your Header outside the drawer div.

you can see the scroll bar appears right after your Header, include Header inside your drawer-content, but your layout will change and it will look like this

Screenshot 2023-03-19 at 7 13 22 PM

hebontes avatar Mar 19 '23 15:03 hebontes

Make sure the div structure is the same as mentioned in the docs: https://daisyui.com/components/drawer/

.drawer // The root container
  β”œβ”€β”€ .drawer-toggle // A hidden checkbox to toggle the visibility of the sidebar
  β”œβ”€β”€ .drawer-content // All your page content goes here
  β”‚    β”œβ”€β”€ // navbar
  β”‚    β”œβ”€β”€ // content
  β”‚    └── // footer
  └── .drawer-side // Sidebar wrapper
       β”œβ”€β”€ .drawer-overlay // A dark overlay that covers the whole page when the drawer is open
       └── // Sidebar content (menu or anything)

the drawer class is the container. And all your page content should be inside drawer-content
If your div structure is correct and you don't have other CSS styles (from other sources) that might modify styles, it will work correctly (like this example: https://play.tailwindcss.com/qDEqG17DUq)

If your structure is correct but you see double scrollbars, please share a minimal reproduction repo so we can see the issue. Otherwise it would be so hard to help because we should just guess πŸ˜…

saadeghi avatar Mar 21 '23 18:03 saadeghi

@saadeghi Is it just me or does your example also have double scrollbars? Tested in Chrome Version 117.0.5938.132 (Official Build) (64-bit) and Firefox 121.0 (64-bit)

Mathias-g avatar Jan 09 '24 13:01 Mathias-g