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]: Missing table header class #1981

Open
danie-ramdhani opened this issue Sep 29, 2024 · 12 comments
Open

[Bug]: Missing table header class #1981

danie-ramdhani opened this issue Sep 29, 2024 · 12 comments
Labels
bug Something isn't working

Comments

@danie-ramdhani
Copy link

What happened?

The table header when the column is not sortable, the class is not applied to the label correctly:

Screenshot 2024-09-30 015253

How to reproduce the bug

No response

Package Version

3.4.21

PHP Version

None

Laravel Version

No response

Alpine Version

No response

Theme

Tailwind 3.x

Notes

No response

Error Message

No response

@danie-ramdhani danie-ramdhani added the bug Something isn't working label Sep 29, 2024
@danie-ramdhani danie-ramdhani changed the title [Bug]: Wrong table header class [Bug]: Missing table header class Sep 30, 2024
Copy link

stale bot commented Nov 4, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Nov 4, 2024
@lrljoe lrljoe removed the wontfix This will not be worked on label Nov 4, 2024
@lrljoe
Copy link
Collaborator

lrljoe commented Nov 6, 2024

This should be fixed in 3.5.0, please let me know if not the case!

@lrljoe lrljoe closed this as completed Nov 6, 2024
@danie-ramdhani
Copy link
Author

danie-ramdhani commented Nov 6, 2024

i've upgrade to latest version (3.5.0) + clear the cache and it still missing. and its not the table header class, but the element inside it 😅.

image

@lrljoe
Copy link
Collaborator

lrljoe commented Nov 6, 2024

Can you share what you're doing to create that Column please?

Do you have any custom setThAttributes/setTdAttributes/setTrAttributes in your configure?

@lrljoe lrljoe reopened this Nov 6, 2024
@danie-ramdhani
Copy link
Author

danie-ramdhani commented Nov 7, 2024

i just have regular custom class.

image

to reproduce it is simple. create column that use sortable() and another column is not using it.

image

and in latest version (3.5.0) the span doesn't have basic classes because it's not wrapped inside the button:

image

@lrljoe
Copy link
Collaborator

lrljoe commented Nov 7, 2024

i just have regular custom class.

Just to validate - have you previously published the views?

Will try to replicate what you've got, to see if I can reproduce.

@danie-ramdhani
Copy link
Author

No i don't.

@lrljoe
Copy link
Collaborator

lrljoe commented Nov 8, 2024

No i don't.

Just so I can narrow it down a bit

  $this->setThSortButtonAttributes(function(Column $column) {
    if ($column->isField('deleted_at')) {
      return [
        'class' => 'bg-green-500',
      ];
    }
 
    return [];
  });

I do need to get it all back in alignment, but this should help me focus where the issue is:

@danie-ramdhani
Copy link
Author

ok, so tried it. and when the column is not sortable, it doens't apply the styles:

$this->setThSortButtonAttributes(function (Column $column) {
    if ($column->isField('avatar')) {
        return [
            'class' => 'bg-green-500',
        ];
    }

    if ($column->isField('role')) {
        return [
            'class' => 'bg-green-500',
        ];
    }

    return [];
});

result:

image

like i said before the sortable column is wrapped inside the button (and all the styles is only on the button, not span element)

image

@lrljoe
Copy link
Collaborator

lrljoe commented Nov 8, 2024

Thanks for the detail, I'll try to get a fix out this weekend.

I imagine it'll just need a little bit more specificity in terms of what to return (standard TH vs Sortable TH)

@lrljoe
Copy link
Collaborator

lrljoe commented Nov 8, 2024

Hmmm

$this->setThSortButtonAttributes(function (Column $column) {
    if ($column->isField('avatar')) {
        return [
            'class' => 'bg-green-500',
        ];
    }

    if ($column->isField('role')) {
        return [
            'class' => 'bg-green-500',
        ];
    }

    return [];
});

IS working as expected.

It's applying the "class" attribute you selected (bg-green-500) to the button element for "role".
The Column "avatar" isn't a sortable Column.

image

@lrljoe
Copy link
Collaborator

lrljoe commented Nov 8, 2024

You'd want the "setLabelAttributes" for a Column to set the attributes for the "span", from what I recall.

It's something that does need cleaning up admittedly!

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