Skip to content

Fix. Quickgrid PropertyColumn Align property doesn't work with Align.Right #62707

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

Merged
merged 4 commits into from
Jul 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,23 @@ td.col-justify-end {
text-align: right;
}

.col-justify-start .col-options {
left: 0;
right: unset;
}

td.col-justify-start {
text-align: left;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use in .col-justify-end { text-align: right }. So I just did this class by the same pattern as an existing class.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm. Maybe I'm not fully understanding how this works. But the start and end classes are typically used/defined for usage with logical properties, with the idea, that they automatically adapt to right to left languages like arabic, hebrew and so on

}

td.col-justify-right {
text-align: right;
}

td.col-justify-left {
text-align: left;
}

/* Unfortunately we can't use the :dir pseudoselector due to lack of browser support. Instead we have to rely on
the developer setting <html dir="rtl"> to detect if we're in RTL mode. */
html[dir=rtl] td.col-justify-end {
Expand All @@ -91,6 +108,10 @@ html[dir=rtl] .col-options {
right: 0;
}

html[dir=rtl] td.col-justify-start {
text-align: right;
}

html[dir=rtl] .col-justify-end .col-options {
right: unset;
left: 0;
Expand Down
18 changes: 18 additions & 0 deletions src/Components/test/E2ETest/Tests/QuickGridTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
using Microsoft.AspNetCore.E2ETesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Support.Extensions;
using Xunit.Abstractions;

namespace Microsoft.AspNetCore.Components.E2ETests.Tests;
Expand Down Expand Up @@ -149,6 +150,23 @@ public void RowClassApplied()
}
}

[Fact]
public void RowStyleApplied()
{
var grid = app.FindElement(By.CssSelector("#grid > table"));
var birthDateColumn = grid.FindElement(By.CssSelector("thead > tr > th:nth-child(4)"));
var ageColumn = grid.FindElement(By.CssSelector("thead > tr > th:nth-child(5)"));

Assert.Contains("col-justify-center", birthDateColumn.GetAttribute("class"));
Assert.Contains("col-justify-right", ageColumn.GetAttribute("class"));
Assert.Equal("center", Browser.ExecuteJavaScript<string>(@"
const p = document.querySelector('tbody > tr:first-child > td:nth-child(4)');
return p ? getComputedStyle(p).textAlign : null;"));
Assert.Equal("right", Browser.ExecuteJavaScript<string>(@"
const p = document.querySelector('tbody > tr:first-child > td:nth-child(5)');
return p ? getComputedStyle(p).textAlign : null;"));
}

[Fact]
public void CanOpenColumnOptions()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
</ColumnOptions>
</PropertyColumn>
<PropertyColumn Property="@(p => p.LastName)" Sortable="true" />
<PropertyColumn Property="@(p => p.BirthDate)" Format="yyyy-MM-dd" Sortable="true" />
<PropertyColumn Title="Age in years" Property="@(p => ComputeAge(p.BirthDate))" Sortable="true"/>
<PropertyColumn Property="@(p => p.BirthDate)" Format="yyyy-MM-dd" Sortable="true" Align="Align.Center" />
<PropertyColumn Title="Age in years" Property="@(p => ComputeAge(p.BirthDate))" Sortable="true" Align="Align.Right"/>
</QuickGrid>
</div>
<Paginator State="@pagination" />
Expand Down
Loading