z-song / laravel-admin

Build a full-featured administrative interface in ten minutes
https://laravel-admin.org
MIT License
11.15k stars 2.82k forks source link

Too many labels in grid column #5723

Open anxgstadler opened 1 year ago

anxgstadler commented 1 year ago

Description:

When there are too many labels for a Grid column, the column grows and grows in width without breaking to a second or even third line. This is caused by using non-breaking spaces as separator in Encore\Admin\Grid\Displayers\Label.

We are using laravel admin in a fairly complex project with many permissions, and the "Roles" page has become quite unusable by now because every line is longer than one or even two screens ;-)

Proposed changes: 1) Use regular space as separator 2) Since this would be a BC issue for some users, we could introduce a second optional parameter bool $allowLineBreaksBetweenLabels = false that could be set to true in cases where you want to allow line breaks between labels (like on the "Roles" page)

I will happily provide a small pull request if the feature is met with approval.

alexoleynik0 commented 1 year ago

I agree that this is a bit annoying, but it can be "fixed" by adding max-width and word-break to the column.

$grid->column('tags', __('Tags'))
    ->pluck('name')
    ->label('default')
    ->style('max-width: 220px; word-break: break-word;')
;
anxgstadler commented 1 year ago

This in indeed a nice idea. The thing is: I'm talking of the "Roles" page within laravel admin itself. So I need to do it via pull request anyway, either changing only this one page, or addressing the root of the cause.

alexoleynik0 commented 1 year ago

Oh, I see. Don't know if there's a reason to use   between some html elements.. Maybe there's one, who knows.