Skip to content

Commit f8f2269

Browse files
vnbaaijCopilot
andauthored
[DataGrid] Fix resize indicator height (when ResizeColumnOnAllRows is true) (#4383)
* Fix #4378 by removing default header padding * Update src/Core/Components/DataGrid/FluentDataGrid.razor Co-authored-by: Copilot <[email protected]> * Update veriefied files * Fix comment --------- Co-authored-by: Copilot <[email protected]>
1 parent 746294e commit f8f2269

14 files changed

+28
-26
lines changed

src/Core/Components/DataGrid/FluentDataGrid.razor

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@
201201

202202
@if (ResizableColumns)
203203
{
204-
<div class="resize-handle"></div>
204+
var top = DisplayMode == DataGridDisplayMode.Table ? "top: 4px;" : "top: 2px;";
205+
<div class="resize-handle" style="@top"></div>
205206
}
206207
</FluentDataGridCell>
207208
}

src/Core/Components/DataGrid/FluentDataGrid.razor.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767

6868
::deep .resize-handle {
6969
position: absolute;
70-
top: 5px;
7170
right: 0;
7271
left: unset;
7372
bottom: 0;

src/Core/Components/DataGrid/FluentDataGrid.razor.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export function enableColumnResizing(gridElement, resizeColumnOnAllRows = true)
188188
if (!resizeColumnOnAllRows) {
189189
// Only use the header height when resizeColumnOnAllRows is false
190190
// Use the first header's height if available
191-
resizeHandleHeight = headers.length > 0 ? (headers[0].offsetHeight - 14 ): 30; // fallback to 30px if no headers
191+
resizeHandleHeight = headers.length > 0 ? (headers[0].offsetHeight - 14 ): 32; // fallback to 32px if no headers
192192
}
193193

194194
headers.forEach((header) => {
@@ -201,8 +201,11 @@ export function enableColumnResizing(gridElement, resizeColumnOnAllRows = true)
201201
const resizedivs = header.querySelectorAll(".actual-resize-handle");
202202
resizedivs.forEach(div => div.remove());
203203

204+
// Get the top of the first resize-handle
205+
const resizeTop = header.querySelector('.resize-handle').offsetTop;
206+
204207
// add a new resize div
205-
const div = createDiv(resizeHandleHeight, isRTL);
208+
const div = createDiv(resizeHandleHeight, resizeTop, isRTL);
206209
header.appendChild(div);
207210
setListeners(div, isRTL);
208211
});
@@ -283,14 +286,14 @@ export function enableColumnResizing(gridElement, resizeColumnOnAllRows = true)
283286
});
284287
}
285288

286-
function createDiv(height, isRTL) {
289+
function createDiv(height, top, isRTL) {
287290
const div = document.createElement('div');
288291
div.className = "actual-resize-handle";
289-
div.style.top = '5px';
292+
div.style.top = top + 'px';
290293
div.style.position = 'absolute';
291294
div.style.cursor = 'col-resize';
292295
div.style.userSelect = 'none';
293-
div.style.height = (height - 5) + 'px';
296+
div.style.height = (height - 4) + 'px';
294297
div.style.width = '6px';
295298
div.style.opacity = 'var(--fluent-data-grid-header-opacity)'
296299

src/Core/Components/DataGrid/FluentDataGridCell.razor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public partial class FluentDataGridCell<TGridItem> : FluentComponentBase
7979
.AddStyle("height", $"{Grid.ItemSize:0}px", () => !Grid.EffectiveLoadingValue && Grid.Virtualize)
8080
.AddStyle("height", $"{(int)Grid.RowSize}px", () => !Grid.EffectiveLoadingValue && !Grid.Virtualize && !Grid.MultiLine && (Grid.Items is not null || Grid.ItemsProvider is not null) && InternalGridContext.TotalItemCount > 0)
8181
.AddStyle("height", "100%", Grid.MultiLine)
82-
.AddStyle("min-height", "44px", Owner.RowType != DataGridRowType.Default)
82+
.AddStyle("min-height", "40px", Owner.RowType != DataGridRowType.Default)
8383
.AddStyle("z-index", ZIndex.DataGridHeaderPopup.ToString(), CellType == DataGridCellType.ColumnHeader && Grid._columns.Count > 0 && Grid.UseMenuService)
8484
.AddStyle(Owner.Style)
8585
.Build();

src/Core/Components/DataGrid/FluentDataGridCell.razor.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ td.grid-cell-placeholder:after {
5050
font-weight: 600;
5151
text-align: center;
5252
position: relative;
53-
padding: calc((var(--design-unit) + var(--focus-stroke-width) - var(--stroke-width)) * 1px) 1px calc((var(--design-unit) + var(--focus-stroke-width) - var(--stroke-width)) * 1px);
5453
}
5554

5655
::deep .col-sort-button {

tests/Core/DataGrid/DataGridSortByTests.DataGridSortByTests_SortByColumnIndex_Ascending.verified.razor.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<table id="xxx" class="fluent-data-grid grid" style="grid-template-columns: 1fr 1fr;" aria-rowcount="5" blazor:onclosecolumnoptions="1" blazor:onclosecolumnresize="2" b-ppmhrkw1mj="" blazor:elementreference="">
33
<thead b-ppmhrkw1mj="">
44
<tr class="fluent-data-grid-row" data-row-index="0" role="row" row-type="header" blazor:onkeydown="3" blazor:onclick="4" blazor:ondblclick="5" blazor:onfocus="6" b-upi3f9mbnn="">
5-
<th col-index="1" class="column-header col-justify-start col-sort-asc" style="grid-column: 1; min-width: 100px; height: 32px; min-height: 44px; z-index: 5;" blazor:oncontextmenu:preventdefault="" blazor:onkeydown="27" blazor:onclick="28" blazor:onfocus="29" scope="col" aria-sort="ascending" b-w6qdxfylwy="">
5+
<th col-index="1" class="column-header col-justify-start col-sort-asc" style="grid-column: 1; min-width: 100px; height: 32px; min-height: 40px; z-index: 5;" blazor:oncontextmenu:preventdefault="" blazor:onkeydown="27" blazor:onclick="28" blazor:onfocus="29" scope="col" aria-sort="ascending" b-w6qdxfylwy="">
66
<div style="display: flex; justify-content: flex-start;" b-pxhtqoo8qd="">
77
<span class="keycapture" style="width: 100%;" blazor:oncontextmenu="57" blazor:elementreference="">
88
<fluent-button class="col-sort-button" style="width: calc(100% - 10px);" type="button" appearance="stealth" blazor:onclick="58" b-x1200685t0="" blazor:elementreference="">
@@ -14,7 +14,7 @@
1414
</span>
1515
</div>
1616
</th>
17-
<th col-index="2" class="column-header col-justify-start" style="grid-column: 2; min-width: 100px; height: 32px; min-height: 44px; z-index: 5;" blazor:oncontextmenu:preventdefault="" blazor:onkeydown="30" blazor:onclick="31" blazor:onfocus="32" scope="col" aria-sort="none" b-w6qdxfylwy="">
17+
<th col-index="2" class="column-header col-justify-start" style="grid-column: 2; min-width: 100px; height: 32px; min-height: 40px; z-index: 5;" blazor:oncontextmenu:preventdefault="" blazor:onkeydown="30" blazor:onclick="31" blazor:onfocus="32" scope="col" aria-sort="none" b-w6qdxfylwy="">
1818
<div style="display: flex; justify-content: flex-start;" b-pxhtqoo8qd="">
1919
<div class="col-title" style="width: calc(100% - 10px);" b-pxhtqoo8qd="">
2020
<div class="col-title-text" b-pxhtqoo8qd="">Item2</div>

tests/Core/DataGrid/DataGridSortByTests.DataGridSortByTests_SortByColumnIndex_Descending.verified.razor.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<table id="xxx" class="fluent-data-grid grid" style="grid-template-columns: 1fr 1fr;" aria-rowcount="5" blazor:onclosecolumnoptions="1" blazor:onclosecolumnresize="2" b-ppmhrkw1mj="" blazor:elementreference="">
33
<thead b-ppmhrkw1mj="">
44
<tr class="fluent-data-grid-row" data-row-index="0" role="row" row-type="header" blazor:onkeydown="3" blazor:onclick="4" blazor:ondblclick="5" blazor:onfocus="6" b-upi3f9mbnn="">
5-
<th col-index="1" class="column-header col-justify-start col-sort-desc" style="grid-column: 1; min-width: 100px; height: 32px; min-height: 44px; z-index: 5;" blazor:oncontextmenu:preventdefault="" blazor:onkeydown="27" blazor:onclick="28" blazor:onfocus="29" scope="col" aria-sort="descending" b-w6qdxfylwy="">
5+
<th col-index="1" class="column-header col-justify-start col-sort-desc" style="grid-column: 1; min-width: 100px; height: 32px; min-height: 40px; z-index: 5;" blazor:oncontextmenu:preventdefault="" blazor:onkeydown="27" blazor:onclick="28" blazor:onfocus="29" scope="col" aria-sort="descending" b-w6qdxfylwy="">
66
<div style="display: flex; justify-content: flex-start;" b-pxhtqoo8qd="">
77
<span class="keycapture" style="width: 100%;" blazor:oncontextmenu="57" blazor:elementreference="">
88
<fluent-button class="col-sort-button" style="width: calc(100% - 10px);" type="button" appearance="stealth" blazor:onclick="58" b-x1200685t0="" blazor:elementreference="">
@@ -14,7 +14,7 @@
1414
</span>
1515
</div>
1616
</th>
17-
<th col-index="2" class="column-header col-justify-start" style="grid-column: 2; min-width: 100px; height: 32px; min-height: 44px; z-index: 5;" blazor:oncontextmenu:preventdefault="" blazor:onkeydown="30" blazor:onclick="31" blazor:onfocus="32" scope="col" aria-sort="none" b-w6qdxfylwy="">
17+
<th col-index="2" class="column-header col-justify-start" style="grid-column: 2; min-width: 100px; height: 32px; min-height: 40px; z-index: 5;" blazor:oncontextmenu:preventdefault="" blazor:onkeydown="30" blazor:onclick="31" blazor:onfocus="32" scope="col" aria-sort="none" b-w6qdxfylwy="">
1818
<div style="display: flex; justify-content: flex-start;" b-pxhtqoo8qd="">
1919
<div class="col-title" style="width: calc(100% - 10px);" b-pxhtqoo8qd="">
2020
<div class="col-title-text" b-pxhtqoo8qd="">Item2</div>

tests/Core/DataGrid/DataGridSortByTests.DataGridSortByTests_SortByColumnTitle_Ascending.verified.razor.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<table id="xxx" class="fluent-data-grid grid" style="grid-template-columns: 1fr 1fr;" aria-rowcount="5" blazor:onclosecolumnoptions="1" blazor:onclosecolumnresize="2" b-ppmhrkw1mj="" blazor:elementreference="">
33
<thead b-ppmhrkw1mj="">
44
<tr class="fluent-data-grid-row" data-row-index="0" role="row" row-type="header" blazor:onkeydown="3" blazor:onclick="4" blazor:ondblclick="5" blazor:onfocus="6" b-upi3f9mbnn="">
5-
<th col-index="1" class="column-header col-justify-start col-sort-asc" style="grid-column: 1; min-width: 100px; height: 32px; min-height: 44px; z-index: 5;" blazor:oncontextmenu:preventdefault="" blazor:onkeydown="27" blazor:onclick="28" blazor:onfocus="29" scope="col" aria-sort="ascending" b-w6qdxfylwy="">
5+
<th col-index="1" class="column-header col-justify-start col-sort-asc" style="grid-column: 1; min-width: 100px; height: 32px; min-height: 40px; z-index: 5;" blazor:oncontextmenu:preventdefault="" blazor:onkeydown="27" blazor:onclick="28" blazor:onfocus="29" scope="col" aria-sort="ascending" b-w6qdxfylwy="">
66
<div style="display: flex; justify-content: flex-start;" b-pxhtqoo8qd="">
77
<span class="keycapture" style="width: 100%;" blazor:oncontextmenu="57" blazor:elementreference="">
88
<fluent-button class="col-sort-button" style="width: calc(100% - 10px);" type="button" appearance="stealth" blazor:onclick="58" b-x1200685t0="" blazor:elementreference="">
@@ -14,7 +14,7 @@
1414
</span>
1515
</div>
1616
</th>
17-
<th col-index="2" class="column-header col-justify-start" style="grid-column: 2; min-width: 100px; height: 32px; min-height: 44px; z-index: 5;" blazor:oncontextmenu:preventdefault="" blazor:onkeydown="30" blazor:onclick="31" blazor:onfocus="32" scope="col" aria-sort="none" b-w6qdxfylwy="">
17+
<th col-index="2" class="column-header col-justify-start" style="grid-column: 2; min-width: 100px; height: 32px; min-height: 40px; z-index: 5;" blazor:oncontextmenu:preventdefault="" blazor:onkeydown="30" blazor:onclick="31" blazor:onfocus="32" scope="col" aria-sort="none" b-w6qdxfylwy="">
1818
<div style="display: flex; justify-content: flex-start;" b-pxhtqoo8qd="">
1919
<div class="col-title" style="width: calc(100% - 10px);" b-pxhtqoo8qd="">
2020
<div class="col-title-text" b-pxhtqoo8qd="">Item2</div>

tests/Core/DataGrid/DataGridSortByTests.DataGridSortByTests_SortByColumnTitle_Descending.verified.razor.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<table id="xxx" class="fluent-data-grid grid" style="grid-template-columns: 1fr 1fr;" aria-rowcount="5" blazor:onclosecolumnoptions="1" blazor:onclosecolumnresize="2" b-ppmhrkw1mj="" blazor:elementreference="">
33
<thead b-ppmhrkw1mj="">
44
<tr class="fluent-data-grid-row" data-row-index="0" role="row" row-type="header" blazor:onkeydown="3" blazor:onclick="4" blazor:ondblclick="5" blazor:onfocus="6" b-upi3f9mbnn="">
5-
<th col-index="1" class="column-header col-justify-start col-sort-desc" style="grid-column: 1; min-width: 100px; height: 32px; min-height: 44px; z-index: 5;" blazor:oncontextmenu:preventdefault="" blazor:onkeydown="27" blazor:onclick="28" blazor:onfocus="29" scope="col" aria-sort="descending" b-w6qdxfylwy="">
5+
<th col-index="1" class="column-header col-justify-start col-sort-desc" style="grid-column: 1; min-width: 100px; height: 32px; min-height: 40px; z-index: 5;" blazor:oncontextmenu:preventdefault="" blazor:onkeydown="27" blazor:onclick="28" blazor:onfocus="29" scope="col" aria-sort="descending" b-w6qdxfylwy="">
66
<div style="display: flex; justify-content: flex-start;" b-pxhtqoo8qd="">
77
<span class="keycapture" style="width: 100%;" blazor:oncontextmenu="57" blazor:elementreference="">
88
<fluent-button class="col-sort-button" style="width: calc(100% - 10px);" type="button" appearance="stealth" blazor:onclick="58" b-x1200685t0="" blazor:elementreference="">
@@ -14,7 +14,7 @@
1414
</span>
1515
</div>
1616
</th>
17-
<th col-index="2" class="column-header col-justify-start" style="grid-column: 2; min-width: 100px; height: 32px; min-height: 44px; z-index: 5;" blazor:oncontextmenu:preventdefault="" blazor:onkeydown="30" blazor:onclick="31" blazor:onfocus="32" scope="col" aria-sort="none" b-w6qdxfylwy="">
17+
<th col-index="2" class="column-header col-justify-start" style="grid-column: 2; min-width: 100px; height: 32px; min-height: 40px; z-index: 5;" blazor:oncontextmenu:preventdefault="" blazor:onkeydown="30" blazor:onclick="31" blazor:onfocus="32" scope="col" aria-sort="none" b-w6qdxfylwy="">
1818
<div style="display: flex; justify-content: flex-start;" b-pxhtqoo8qd="">
1919
<div class="col-title" style="width: calc(100% - 10px);" b-pxhtqoo8qd="">
2020
<div class="col-title-text" b-pxhtqoo8qd="">Item2</div>

tests/Core/DataGrid/FluentDataGridColumSelectTests.FluentDataGrid_ColumSelect_MultiSelect_Customized_Rendering.verified.razor.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<table id="xxx" class="fluent-data-grid grid" style="grid-template-columns: 50px auto;" aria-rowcount="4" blazor:onclosecolumnoptions="1" blazor:onclosecolumnresize="2" b-ppmhrkw1mj="" blazor:elementreference="">
33
<thead b-ppmhrkw1mj="">
44
<tr class="fluent-data-grid-row" data-row-index="0" role="row" row-type="header" blazor:onkeydown="3" blazor:onclick="4" blazor:ondblclick="5" blazor:onfocus="6" b-upi3f9mbnn="">
5-
<th col-index="1" class="column-header select-all col-justify-center" style="grid-column: 1; text-align: center; align-content: center; min-width: 50px; padding-top: calc(var(--design-unit) * 2.5px); height: 32px; min-height: 44px; z-index: 5;" blazor:oncontextmenu:preventdefault="" blazor:onkeydown="23" blazor:onclick="24" blazor:onfocus="25" scope="col" aria-sort="none" b-w6qdxfylwy="">
5+
<th col-index="1" class="column-header select-all col-justify-center" style="grid-column: 1; text-align: center; align-content: center; min-width: 50px; padding-top: calc(var(--design-unit) * 2.5px); height: 32px; min-height: 40px; z-index: 5;" blazor:oncontextmenu:preventdefault="" blazor:onkeydown="23" blazor:onclick="24" blazor:onfocus="25" scope="col" aria-sort="none" b-w6qdxfylwy="">
66
<div style="cursor: pointer; margin-left: 12px;" blazor:onclick="26" blazor:onkeydown="27"></div>
77
</th>
8-
<th col-index="2" class="column-header col-justify-start" style="grid-column: 2; min-width: 100px; height: 32px; min-height: 44px; z-index: 5;" blazor:oncontextmenu:preventdefault="" blazor:onkeydown="28" blazor:onclick="29" blazor:onfocus="30" scope="col" aria-sort="none" b-w6qdxfylwy="">
8+
<th col-index="2" class="column-header col-justify-start" style="grid-column: 2; min-width: 100px; height: 32px; min-height: 40px; z-index: 5;" blazor:oncontextmenu:preventdefault="" blazor:onkeydown="28" blazor:onclick="29" blazor:onfocus="30" scope="col" aria-sort="none" b-w6qdxfylwy="">
99
<div style="display: flex; justify-content: flex-start;" b-pxhtqoo8qd="">
1010
<div class="col-title" style="width: calc(100% - 10px);" b-pxhtqoo8qd="">
1111
<div class="col-title-text" b-pxhtqoo8qd="">Name</div>

0 commit comments

Comments
 (0)