Skip to content

bug: li elements under .menu have text-wrap: balance #4329

@AtmoFX

Description

@AtmoFX

Reproduction URL (Required)

https://play.tailwindcss.com/KvjqgTCqhg

What version of daisyUI are you using?

v5.5.8

Which browsers are you seeing the problem on?

All browsers

Describe your issue

Following the discussions in:

I agree with the message that:

We shouldn't break the text by default nor we shouldn't make the menu to grow by the content width because in both cases, it breaks layouts if the text is long. We shouldn't also set a default width because this design decision depends on the design and the content of the page.

But precisely, the choice to break the text by default has been made when line 29 of menu.css (text-wrap: balance) was added. On that, I do not understand why wrap was not enough considering menu items are expected to have very short texts.

I believe the reason why this stayed hidden is because it only makes menu components misbehave when they are inside a dropdown and if the text on the trigger button is short enough. From the repro URL:

  • In amber, 1 menu where the button as a long enough text the dropdown has not word wrap (this is for reference).
  • In green, 2 menus where I tried to force text-nowrap, letting the width be implicit; only 1 menu is inside a dropdown.
  • In red, 2 menus where I force a limited width, letting words wrap

Now, if I disable text-wrap: balance in my browser's developer's tools (tested with Chrome and Firefox), everything is well-behaved. Here is a capture of my screen before and after doing that:

Image

I suggest that very line 29 should be removed.


PS: I am of course aware I can force class="text-nowrap" on the <a> elements in the dropdown menu. However:

  • That creates extra code.
  • That does not mix nicely (or at all, really) with my dev workflow, where I create Laravel Blade components for others to use.
  • That leaves the "computationally expensive" text-wrap: balance in a place where it does not look necessary though of course users could choose to force it themselves if they are not satistifed with the CSS default for that property (wrap)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions