filament icon indicating copy to clipboard operation
filament copied to clipboard

`ImageColumn` clashes with methods on `HasWidth` trait

Open adevade opened this issue 1 year ago • 1 comments

Package

filament/tables

Package Version

v3.2.92

Laravel Version

v11.11.1

Livewire Version

v3.5.1

PHP Version

PHP v8.3.8

Problem description

image

If you set ->width('1%') on an ImageColumn the header and image gets the width value.

Expected behavior

I would expect the ->width() method to do the same thing for all columns. Right now it sets the column header width on all but ImageColumn (I believe). For ImageColumn it sets the column width AND the image width.

Steps to reproduce

// This squeezes the image width AND the column header width.
Tables\Columns\ImageColumn::make('smushed_avatar')
    ->state('https://gravatar.com/avatar/foo?d=mp&f=y')
    ->width('1%'),

// This works as expected, like on other columns using the `HasWidth` trait.
Tables\Columns\ImageColumn::make('normal_avatar')
    ->state('https://gravatar.com/avatar/foo?d=mp&f=y')
    ->extraHeaderAttributes(['style' => 'width: 1%']),

Login info for reproduction repo: [email protected] password

Reproduction repository (issue will be closed if this is not valid)

https://github.com/adevade/filament-image-column-width-bug

Relevant log output

No response

Donate 💰 to fund this issue

  • You can donate funding to this issue. We receive the money once the issue is completed & confirmed by you.
  • 100% of the funding will be distributed between the Filament core team to run all aspects of the project.
  • Thank you in advance for helping us make maintenance sustainable!
Fund with Polar

adevade avatar Jun 22 '24 12:06 adevade

One suggestion is to rename the HasWidth trait and methods to something like HasHeaderWidth or HasColumnWidth like it was originally in the mentioned PR. Technically I guess it just sets the width on the header row, but ->columnWidth() might be a more obvious name?

adevade avatar Jun 22 '24 12:06 adevade

In v4, width() has been renamed to imageWidth()

danharrin avatar Dec 18 '24 10:12 danharrin