flowbite icon indicating copy to clipboard operation
flowbite copied to clipboard

Multi-level dropdown is not responsive.

Open MattJonesSiteglide opened this issue 3 years ago • 5 comments

Describe the bug

In the mobile example for multi-level dropdowns (and in my site), the second level of dropdown falls off the edge of the page. Since the anchor text is quite short, I don't think this is due to content. See screenshot.

To Reproduce Steps to reproduce the behavior:

  1. In the docs, click the mobile view for https://flowbite.com/blocks/marketing/header/#header-with-dropdown-menu .

Expected behavior

With short link titles, the 2nd level of dropdown should not overflow the edge of the page on mobile, but be positioned somewhere on the page.

I'm not sure where that somewhere should be! I think this is quite a difficult design to make responsive. Some sites would show these as a collapsible vertical list nested inside the parent component in mobile.

However, it may be possible to adjust the "popper.js" placement to get the intended behaviour.

Screenshots image

Desktop (please complete the following information):

  • OS: Windows
  • Browser Chrome
  • Version Version 103.0.5060.114 (Official Build) (64-bit)

Additional context Add any other context about the problem here.

MattJonesSiteglide avatar Jul 12 '22 14:07 MattJonesSiteglide

Currently I get the best results with putting data-dropdown-placement="bottom-start" on the first level, then "right-start" on the 2nd level. Though content also needs to be kept short- this seems like a good default for the example?

MattJonesSiteglide avatar Jul 12 '22 14:07 MattJonesSiteglide

Hey @MattJonesSiteglide,

Fair point, will look into this.

zoltanszogyenyi avatar Jul 14 '22 09:07 zoltanszogyenyi

Thanks! I always struggle with dropdowns on mobile myself!

MattJonesSiteglide avatar Jul 15 '22 08:07 MattJonesSiteglide

Perhaps one way to solve this would be to make the appended inline style conditional (based on the viewport size, or allow the end-user to specify at which breakpoint/s to enable it). Simply removing the absolute positioning and the translate that is dynamically added makes things much better looking on smaller devices.

Before After
image image

ianmuscat avatar Sep 17 '23 17:09 ianmuscat