Skip to content

Commit 292fe52

Browse files
authored
Fix. Quickgrid PropertyColumn Align property doesn't work with Align.Right (#62707)
1 parent 8bb2b20 commit 292fe52

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/QuickGrid.razor.css

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,23 @@ td.col-justify-end {
8080
text-align: right;
8181
}
8282

83+
.col-justify-start .col-options {
84+
left: 0;
85+
right: unset;
86+
}
87+
88+
td.col-justify-start {
89+
text-align: left;
90+
}
91+
92+
td.col-justify-right {
93+
text-align: right;
94+
}
95+
96+
td.col-justify-left {
97+
text-align: left;
98+
}
99+
83100
/* Unfortunately we can't use the :dir pseudoselector due to lack of browser support. Instead we have to rely on
84101
the developer setting <html dir="rtl"> to detect if we're in RTL mode. */
85102
html[dir=rtl] td.col-justify-end {
@@ -91,6 +108,10 @@ html[dir=rtl] .col-options {
91108
right: 0;
92109
}
93110

111+
html[dir=rtl] td.col-justify-start {
112+
text-align: right;
113+
}
114+
94115
html[dir=rtl] .col-justify-end .col-options {
95116
right: unset;
96117
left: 0;

src/Components/test/E2ETest/Tests/QuickGridTest.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
99
using Microsoft.AspNetCore.E2ETesting;
1010
using OpenQA.Selenium;
11+
using OpenQA.Selenium.Support.Extensions;
1112
using Xunit.Abstractions;
1213

1314
namespace Microsoft.AspNetCore.Components.E2ETests.Tests;
@@ -149,6 +150,23 @@ public void RowClassApplied()
149150
}
150151
}
151152

153+
[Fact]
154+
public void RowStyleApplied()
155+
{
156+
var grid = app.FindElement(By.CssSelector("#grid > table"));
157+
var birthDateColumn = grid.FindElement(By.CssSelector("thead > tr > th:nth-child(4)"));
158+
var ageColumn = grid.FindElement(By.CssSelector("thead > tr > th:nth-child(5)"));
159+
160+
Assert.Contains("col-justify-center", birthDateColumn.GetAttribute("class"));
161+
Assert.Contains("col-justify-right", ageColumn.GetAttribute("class"));
162+
Assert.Equal("center", Browser.ExecuteJavaScript<string>(@"
163+
const p = document.querySelector('tbody > tr:first-child > td:nth-child(4)');
164+
return p ? getComputedStyle(p).textAlign : null;"));
165+
Assert.Equal("right", Browser.ExecuteJavaScript<string>(@"
166+
const p = document.querySelector('tbody > tr:first-child > td:nth-child(5)');
167+
return p ? getComputedStyle(p).textAlign : null;"));
168+
}
169+
152170
[Fact]
153171
public void CanOpenColumnOptions()
154172
{

src/Components/test/testassets/BasicTestApp/QuickGridTest/SampleQuickGridComponent.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
</ColumnOptions>
1515
</PropertyColumn>
1616
<PropertyColumn Property="@(p => p.LastName)" Sortable="true" />
17-
<PropertyColumn Property="@(p => p.BirthDate)" Format="yyyy-MM-dd" Sortable="true" />
18-
<PropertyColumn Title="Age in years" Property="@(p => ComputeAge(p.BirthDate))" Sortable="true"/>
17+
<PropertyColumn Property="@(p => p.BirthDate)" Format="yyyy-MM-dd" Sortable="true" Align="Align.Center" />
18+
<PropertyColumn Title="Age in years" Property="@(p => ComputeAge(p.BirthDate))" Sortable="true" Align="Align.Right"/>
1919
</QuickGrid>
2020
</div>
2121
<Paginator State="@pagination" />

0 commit comments

Comments
 (0)