laravel-livewire-tables icon indicating copy to clipboard operation
laravel-livewire-tables copied to clipboard

[Bug]: setThAttributes default Flag not working

Open Kell opened this issue 1 year ago • 0 comments

What happened?

It seems the " 'default' => true" ist not working when applied in setThAttributes();

Expected behaviour: use default = true gives the same result when using default-colors = true and default-styling = true;

How to reproduce the bug

For this case we just take a look at the column "Action". Adding custom class

$this->setThAttributes(function(Column $column) {
	$title = $column->getTitle();

	switch ($title) {
		case 'Actions':
			return [
				'class' => 'colum-action',
				];
			break;
		}

		return [];
});

results in different style on the Action colum Bildschirmfoto 2024-10-14 um 11 53 28

added default flag as described in https://rappasoft.com/docs/laravel-livewire-tables/v3/columns/styling#content-keeping-default-colors-and-default-styling

$this->setThAttributes(function(Column $column) {
	$title = $column->getTitle();
	switch ($title) {
		case 'Actions':
			return [
                                 'default' => true,
				'class' => 'colum-action',
			];
			break;
		}

		return ['default' => true];
});

this change do nothing, column header looks same way as before: Bildschirmfoto 2024-10-14 um 11 55 57 Bildschirmfoto 2024-10-14 um 11 57 30 default classes are still overridden

Now if i add only default-styling:

$this->setThAttributes(function(Column $column) {
	$title = $column->getTitle();

	switch ($title) {
		case 'Actions':
			return [
                                  'default-styling' => true,
				'class' => 'colum-action',
			];
			break;
	}

	return ['default-styling' => true];
});

this shows effect: Bildschirmfoto 2024-10-14 um 12 00 58 Bildschirmfoto 2024-10-14 um 12 01 28

if i add default-colors:

$this->setThAttributes(function(Column $column) {
	$title = $column->getTitle();

	switch ($title) {
		case 'Actions':
			return [
                                  'default-styling' => true,
                                   'default-colors' => true,
				  'class' => 'colum-action',
		];
		break;
	}

	return ['default-styling' => true, 'default-colors' => true];
});

it also works: Bildschirmfoto 2024-10-14 um 12 03 29 Bildschirmfoto 2024-10-14 um 12 03 54

The docs says #Keep Default Colors And Default Styles set default flag to true or set default-colors flag to true set default-styling flag to true

i can use default OR the other two, but as shown above the default flag does nothing.

Using 3.4.22 version, but it seems it is in since 3.4.21.

Package Version

3.4.22

PHP Version

8.2.x

Laravel Version

11.27.2

Alpine Version

No response

Theme

Tailwind 3.x

Notes

No response

Error Message

No response

Kell avatar Oct 14 '24 10:10 Kell