Skip to content

[DataGrid] Tweak new resize behavior #3787

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 5 commits into from
May 19, 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
21 changes: 8 additions & 13 deletions src/Core/Components/DataGrid/Columns/ColumnBase.razor
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@
{
if (Grid.SortByAscending == true)
{
<FluentIcon Value="@(new CoreIcons.Regular.Size20.ArrowSortUp())" Slot="@(Align == Align.End ? "start" : "end")" Style="opacity: 0.5;" />
<FluentIcon Value="@(new CoreIcons.Regular.Size20.ArrowSortUp())" Slot="@(Align == Align.End ? "start" : "end")" Style="opacity: var(--fluent-data-grid-header-opacity);" />
}
else
{
<FluentIcon Value="@(new CoreIcons.Regular.Size20.ArrowSortDown())" Slot="@(Align == Align.End ? "start" : "end")" Style="opacity: 0.5;" />
<FluentIcon Value="@(new CoreIcons.Regular.Size20.ArrowSortDown())" Slot="@(Align == Align.End ? "start" : "end")" Style="opacity: var(--fluent-data-grid-header-opacity);" />
}
}
@if (ColumnOptions is not null && Filtered.GetValueOrDefault())
{
<FluentIcon Value="@(new CoreIcons.Regular.Size20.Filter())" Slot="@(Align == Align.End ? "start" : "end")" Style="opacity: 0.5;" />
<FluentIcon Value="@(new CoreIcons.Regular.Size20.Filter())" Slot="@(Align == Align.End ? "start" : "end")" Style="opacity: var(--fluent-data-grid-header-opacity);" />
}
</FluentButton>
}
Expand Down Expand Up @@ -93,11 +93,6 @@
string? wdelta = "10px";
string? align;

if (Grid.ResizeType is not null || ColumnOptions is not null)
{
wdelta = "56px";
}

// determine align string based on Align value
align = Align switch
{
Expand Down Expand Up @@ -133,16 +128,16 @@
{
if (Grid.SortByAscending == true)
{
<FluentIcon Value="@(new CoreIcons.Regular.Size20.ArrowSortUp())" Slot="end" Style="opacity: 0.5;" />
<FluentIcon Value="@(new CoreIcons.Regular.Size20.ArrowSortUp())" Slot="end" Style="opacity: var(--fluent-data-grid-header-opacity);" />
}
else
{
<FluentIcon Value="@(new CoreIcons.Regular.Size20.ArrowSortDown())" Slot="end" Style="opacity: 0.5;" />
<FluentIcon Value="@(new CoreIcons.Regular.Size20.ArrowSortDown())" Slot="end" Style="opacity: var(--fluent-data-grid-header-opacity);" />
}
}
@if (ColumnOptions is not null && Filtered.GetValueOrDefault() && Grid.ResizeType is not null)
{
<FluentIcon Value="@(new CoreIcons.Regular.Size20.Filter())" Slot="end" Style="opacity: 0.5;" />
<FluentIcon Value="@(new CoreIcons.Regular.Size20.Filter())" Slot="end" Style="opacity: var(--fluent-data-grid-header-opacity);" />
}
</FluentButton>
</FluentKeyCode>
Expand All @@ -155,7 +150,7 @@
@if (ColumnOptions is not null && Filtered.GetValueOrDefault() && Grid.ResizeType.HasValue)
{
<span style="padding: 0 5px;">
<FluentIcon Value="@(new CoreIcons.Regular.Size20.Filter())" Slot="end" Style="opacity: 0.5;" />
<FluentIcon Value="@(new CoreIcons.Regular.Size20.Filter())" Slot="end" Style="opacity: var(--fluent-data-grid-header-opacity);" />
</span>
}
</div>
Expand Down Expand Up @@ -194,7 +189,7 @@
{
return
@<FluentButton Appearance="Appearance.Stealth" class="col-options-button" @onclick="@(() => Grid.ShowColumnOptionsAsync(this))" aria-label="Filter this column">
<FluentIcon Value="@(new CoreIcons.Regular.Size20.ChevronDown())" Color="Color.Neutral" Width="20px" Style="opacity: 0.5;" />
<FluentIcon Value="@(new CoreIcons.Regular.Size20.ChevronDown())" Color="Color.Neutral" Width="20px" Style="opacity: var(--fluent-data-grid-header-opacity);" />
</FluentButton>;
}

Expand Down
9 changes: 6 additions & 3 deletions src/Core/Components/DataGrid/FluentDataGrid.razor.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.fluent-data-grid {
--fluent-data-grid-resize-handle-color: var(--accent-fill-rest);
--fluent-data-grid-resize-handle-width: 1px;
--fluent-data-grid-header-opacity: 0.5;
width: auto;
flex: 1;
border-collapse: collapse;
Expand Down Expand Up @@ -64,15 +67,15 @@

::deep .resize-handle {
position: absolute;
top: 6px;
top: 5px;
right: 0;
left: unset;
bottom: 0;
height: 30px;
cursor: col-resize;
width: 6px;
border-inline-end: 1px solid var(--neutral-stroke-divider-rest);
;
border-inline-end: var(--fluent-data-grid-resize-handle-width) solid var(--fluent-data-grid-resize-handle-color);
opacity: var(--fluent-data-grid-header-opacity);
}

.header {
Expand Down
7 changes: 5 additions & 2 deletions src/Core/Components/DataGrid/FluentDataGrid.razor.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ export function enableColumnResizing(gridElement) {
});

div.addEventListener('pointerover', function (e) {
e.target.style.borderInlineEnd = '2px solid var(--neutral-stroke-focus)';
e.target.style.borderInlineEnd = 'var(--fluent-data-grid-resize-handle-width) solid var(--fluent-data-grid-resize-handle-color)';
e.target.previousElementSibling.style.visibility = 'hidden';
});

div.addEventListener('pointerup', removeBorder);
Expand Down Expand Up @@ -273,7 +274,8 @@ export function enableColumnResizing(gridElement) {
div.style.cursor = 'col-resize';
div.style.userSelect = 'none';
div.style.height = height + 'px';
div.style.width = '5px';
div.style.width = '6px';
div.style.opacity = 'var(--fluent-data-grid-header-opacity)'

if (isRTL) {
div.style.left = '0px';
Expand Down Expand Up @@ -301,6 +303,7 @@ export function enableColumnResizing(gridElement) {

function removeBorder(e) {
e.target.style.borderInlineEnd = '';
e.target.previousElementSibling.style.visibility = 'visible';
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/Core/Components/DataGrid/FluentDataGridCell.razor.css
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ td.grid-cell-placeholder:after {
overflow: hidden;
}

::deep .col-options-button {
padding-inline-start: 4px;
}

.col-justify-start ::deep .col-sort-button::part(control) {
justify-content: start;
overflow: hidden;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<span class="keycapture" style="width: 100%;" blazor:oncontextmenu="57" blazor:elementreference="">
<fluent-button class="col-sort-button" style="width: calc(100% - 10px);" type="button" appearance="stealth" blazor:onclick="58" b-x1200685t0="" blazor:elementreference="">
<div class="col-title-text" b-pxhtqoo8qd="">Item1</div>
<svg slot="end" style="width: 20px; fill: var(--accent-fill-rest); opacity: 0.5;" focusable="false" viewBox="0 0 20 20" aria-hidden="true" blazor:onkeydown="59" blazor:onclick="60">
<svg slot="end" style="width: 20px; fill: var(--accent-fill-rest); opacity: var(--fluent-data-grid-header-opacity);" focusable="false" viewBox="0 0 20 20" aria-hidden="true" blazor:onkeydown="59" blazor:onclick="60">
<path d="M9 4.71 6.35 7.35a.5.5 0 1 1-.7-.7L9.1 3.18a.5.5 0 0 1 .74-.03h.01l3.5 3.5a.5.5 0 1 1-.71.7L10 4.71V16.5a.5.5 0 0 1-1 0V4.71Z"></path>
</svg>
</fluent-button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<span class="keycapture" style="width: 100%;" blazor:oncontextmenu="57" blazor:elementreference="">
<fluent-button class="col-sort-button" style="width: calc(100% - 10px);" type="button" appearance="stealth" blazor:onclick="58" b-x1200685t0="" blazor:elementreference="">
<div class="col-title-text" b-pxhtqoo8qd="">Item1</div>
<svg slot="end" style="width: 20px; fill: var(--accent-fill-rest); opacity: 0.5;" focusable="false" viewBox="0 0 20 20" aria-hidden="true" blazor:onkeydown="59" blazor:onclick="60">
<svg slot="end" style="width: 20px; fill: var(--accent-fill-rest); opacity: var(--fluent-data-grid-header-opacity);" focusable="false" viewBox="0 0 20 20" aria-hidden="true" blazor:onkeydown="59" blazor:onclick="60">
<path d="m10 15.29 2.65-2.64a.5.5 0 0 1 .7.7L9.9 16.82a.5.5 0 0 1-.74.03h-.01l-3.5-3.5a.5.5 0 1 1 .71-.7L9 15.29V3.5a.5.5 0 0 1 1 0v11.79Z"></path>
</svg>
</fluent-button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<span class="keycapture" style="width: 100%;" blazor:oncontextmenu="57" blazor:elementreference="">
<fluent-button class="col-sort-button" style="width: calc(100% - 10px);" type="button" appearance="stealth" blazor:onclick="58" b-x1200685t0="" blazor:elementreference="">
<div class="col-title-text" b-pxhtqoo8qd="">Item1</div>
<svg slot="end" style="width: 20px; fill: var(--accent-fill-rest); opacity: 0.5;" focusable="false" viewBox="0 0 20 20" aria-hidden="true" blazor:onkeydown="59" blazor:onclick="60">
<svg slot="end" style="width: 20px; fill: var(--accent-fill-rest); opacity: var(--fluent-data-grid-header-opacity);" focusable="false" viewBox="0 0 20 20" aria-hidden="true" blazor:onkeydown="59" blazor:onclick="60">
<path d="M9 4.71 6.35 7.35a.5.5 0 1 1-.7-.7L9.1 3.18a.5.5 0 0 1 .74-.03h.01l3.5 3.5a.5.5 0 1 1-.71.7L10 4.71V16.5a.5.5 0 0 1-1 0V4.71Z"></path>
</svg>
</fluent-button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<span class="keycapture" style="width: 100%;" blazor:oncontextmenu="57" blazor:elementreference="">
<fluent-button class="col-sort-button" style="width: calc(100% - 10px);" type="button" appearance="stealth" blazor:onclick="58" b-x1200685t0="" blazor:elementreference="">
<div class="col-title-text" b-pxhtqoo8qd="">Item1</div>
<svg slot="end" style="width: 20px; fill: var(--accent-fill-rest); opacity: 0.5;" focusable="false" viewBox="0 0 20 20" aria-hidden="true" blazor:onkeydown="59" blazor:onclick="60">
<svg slot="end" style="width: 20px; fill: var(--accent-fill-rest); opacity: var(--fluent-data-grid-header-opacity);" focusable="false" viewBox="0 0 20 20" aria-hidden="true" blazor:onkeydown="59" blazor:onclick="60">
<path d="m10 15.29 2.65-2.64a.5.5 0 0 1 .7.7L9.9 16.82a.5.5 0 0 1-.74.03h-.01l-3.5-3.5a.5.5 0 1 1 .71-.7L9 15.29V3.5a.5.5 0 0 1 1 0v11.79Z"></path>
</svg>
</fluent-button>
Expand Down
Loading