Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: The TH style is applied twice #1939

Closed
mLicorn opened this issue Sep 10, 2024 · 4 comments
Closed

[Bug]: The TH style is applied twice #1939

mLicorn opened this issue Sep 10, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@mLicorn
Copy link

mLicorn commented Sep 10, 2024

What happened?

When I modify the TH style via the $thAttributesCallback property, the style is also applied to the span in sort button.

How to reproduce the bug

Modify TH padding via the setThAttributes method:

public function configure(): void
{
       $this->setThAttributes(fn() => [
            'default' => false,
            'class'   => 'px-10 py-10'
        ]);
}

Package Version

3.4.20

PHP Version

None

Laravel Version

11.22.0

Alpine Version

3.14.1

Theme

Tailwind 3.x

Notes

The problem comes from the resources/views/components/table/th.blade.php view.

$customAttributes is used for both TH and SPAN in the button.

Error Message

No response

@mLicorn mLicorn added the bug Something isn't working label Sep 10, 2024
@lrljoe
Copy link
Collaborator

lrljoe commented Sep 11, 2024

Good spot! I'll look at getting this fixed for the next release.

@lrljoe
Copy link
Collaborator

lrljoe commented Sep 11, 2024

So I've looked, and the reason behind this is that otherwise the button attributes get applied as it's sortable.

I'll look at adding in the methods to separate this a bit more cleanly!

@lrljoe
Copy link
Collaborator

lrljoe commented Sep 18, 2024

So the fix for this will be in the next release, which adds in a
"setLabelAttributes" for:

  • Actions
  • Columns
  • Filters

This helps to mitigate the issue where the "thAttributes" were being applied twice (once for the th, and once for the label itself).

The underlying reason for this is the clash between setThAttributes and setThSortButtonAttributes

Now there's a setLabelAttributes which applies to the label itself,
Then the setThAttributes, and setThSortButtonAttributes apply to their respective elements only.

Expect the release by the end of the week, or feel free to test it out via the "development" branch

@lrljoe
Copy link
Collaborator

lrljoe commented Sep 25, 2024

This should be fixed in the latest version (3.4.21) - please see above comment!

@lrljoe lrljoe closed this as completed Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants