Skip to content

Commit

Permalink
Table: don't resize columns with FixedPosition (#5925)
Browse files Browse the repository at this point in the history
* Table: don't resize columns with FixedPosition

* Use raw strings

* use switch expression
  • Loading branch information
stsrki authored Jan 8, 2025
1 parent e81e530 commit d660599
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions Source/Blazorise/Components/Table/TableHeaderCell.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@inherits BaseDraggableComponent
<th @ref="@ElementRef" id="@ElementId" scope="col" class="@ClassNames" style="@StyleNames" @onclick="@OnClickHandler" colspan="@ColumnSpan" rowspan="@RowSpan"
draggable="@DraggableString"
data-fixed-position="@FixedPositionDataAttribute"
@ondragend="@OnDragEndHandler"
@ondragend:preventDefault="@DragEndPreventDefault"
@ondragenter="@OnDragEnterHandler"
Expand Down
10 changes: 10 additions & 0 deletions Source/Blazorise/Components/Table/TableHeaderCell.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ protected override ValueTask DisposeAsync( bool disposing )

#region Properties

/// <summary>
/// Gets the fixed position data attribute.
/// </summary>
protected string FixedPositionDataAttribute => FixedPosition switch
{
TableColumnFixedPosition.Start => "start",
TableColumnFixedPosition.End => "end",
_ => null
};

/// <summary>
/// Gets or sets the cascaded parent table component.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions Source/Blazorise/Components/Table/TableRowCell.razor
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
@oncontextmenu="@OnContextMenuHandler"
@oncontextmenu:preventDefault="@ContextMenuPreventDefault"
data-caption="@MobileModeCaption"
data-fixed-position="@FixedPositionDataAttribute"
@attributes="@Attributes">
@ChildContent
</td>
10 changes: 10 additions & 0 deletions Source/Blazorise/Components/Table/TableRowCell.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ protected override ValueTask DisposeAsync( bool disposing )

#region Properties

/// <summary>
/// Gets the fixed position data attribute.
/// </summary>
protected string FixedPositionDataAttribute => FixedPosition switch
{
TableColumnFixedPosition.Start => "start",
TableColumnFixedPosition.End => "end",
_ => null
};

/// <summary>
/// Gets or sets the cascaded parent table component.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Source/Blazorise/wwwroot/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export function initializeResizable(element, elementId, mode) {
return;

// if the column already has both min and max width set, then we don't need to resize it
if (col.style.minWidth && col.style.maxWidth && !col.dataset.resized) {
if (((col.style.minWidth && col.style.maxWidth) || col.dataset.fixedPosition) && !col.dataset.resized) {
return;
}

Expand Down

0 comments on commit d660599

Please sign in to comment.