flowbite icon indicating copy to clipboard operation
flowbite copied to clipboard

Modals going full screen at smaller widths

Open dmf3030 opened this issue 4 years ago • 2 comments

Its possible this is not a bug, but an intended behavior, though I don't know why it would be intended.

Modals carry this styling

<div class="relative p-4 w-full max-w-2xl h-full md:h-auto">

This means modals at mobile widths are defaulting to full height, which in most cases looks off, or at least is not a behavior I would prefer as default. Ideally this can be passed as a prop, left default for anyone currently using it but otherwise could be disabled so that h-auto work across all screen sizes.

dmf3030 avatar Oct 03 '22 01:10 dmf3030

Hello @dmf3030,

This is an automatic feature to enable scroll when most of the time the content inside the modal is longer than the viewport itself. On the other hand, it would probably be better to set this programmatically, so I'll try to push through a feature where you can manage it via data attributes / API.

zoltanszogyenyi avatar Oct 31 '22 15:10 zoltanszogyenyi

My issue is similar enough to this to comment here first before creating a new issue.

I'd ideally like the modal to be able to handle longer content even if it wasn't on a mobile width viewport..? Currently the top of the modal is cut off, see screenshot, where the scrollbar is clearly at the top, but the top of the modal is not visible.

image

To re-create- go into the DOM for the first modal example https://flowbite.com/docs/components/modal/ and copy and paste one of the <p> elements in the modal a few times to make the modal content longer (I tried at full screen viewport, but it could be any I think).

Let me know if this should be a new issue, but if the team is looking into modal height, perhaps a better solution is possible for both mobile and larger viewports at the same time?

Locally- I'm going for the following solution:

  • On the very top div, remove the overflow-y-auto class and add the class max-h-screen
  • On the first child div below that, add both classes max-h-screen & overflow-y-auto

e.g.

<div id="addToSiteModal" tabindex="-1" aria-hidden="true" class="hidden  overflow-x-hidden fixed top-0 right-0 left-0 z-50 w-full md:inset-0 h-modal md:h-full max-h-screen">
    <div class="relative p-4 w-full max-w-2xl h-full md:h-auto  max-h-screen overflow-y-auto">

But there is probably a better way?

MattJonesSiteglide avatar Dec 20 '22 13:12 MattJonesSiteglide