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]: Custom Alignment Overridden by text-start in Table Header #4

Open
elegasoft opened this issue Sep 15, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@elegasoft
Copy link

What happened?

The table header alignment does not match the alignment of the table cells. A sample of the rendered output shows that the text-start class takes precedence over the alignment choice:

<th class="it-table-repeateable-header-cell font-semibold text-gray-950 dark:text-white text-start py-3.5 sm:first-of-type:ps-3 sm:last-of-type:pe-3 text-right justify-end">...</th>

This seems to happen because text-start is hardcoded on line 42 of the Blade file:

<th
@class([
'it-table-repeateable-header-cell font-semibold text-gray-950 dark:text-white text-start py-3.5 sm:first-of-type:ps-3 sm:last-of-type:pe-3',
match ($alignment) {
Alignment::Start => 'text-start',
Alignment::Center => 'text-center',
Alignment::End => 'text-end',
Alignment::Left => 'text-left',
Alignment::Right => 'text-right',
Alignment::Justify, Alignment::Between => 'text-justify',
default => $alignment,
},
match ($alignment) {
Alignment::Start, Alignment::Left => 'justify-start',
Alignment::Center => 'justify-center',
Alignment::End, Alignment::Right => 'justify-end',
Alignment::Between, Alignment::Justify => 'justify-between',
default => null,
}
])
>{{ $label['name'] }}</th>

To fix this, I suggest removing the hardcoded text-start class. If needed, you could modify the matching logic to add text-start as a fallback default when no other alignment is specified.

How to reproduce the bug

To reproduce:

  1. Add a TableRepeatableEntry component.
  2. Attempt to align a column, for example:
TableRepeatableEntry::make('relation')->schema([
    TextEntry::make('column_1')->alignment(Alignment::Right),
]),

Package Version

1.0.3

PHP Version

8.3.10

Laravel Version

11.21.0

Which operating systems does with happen with?

No response

Notes

I could create a PR for this, but I don't know what effect simply removing the hard coded CSS entry will have on other uses, so you may need to consider updating the matching logic as well.

@elegasoft elegasoft added the bug Something isn't working label Sep 15, 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

1 participant