Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Commit

Permalink
Popover uses ElementReference to reference source and target
Browse files Browse the repository at this point in the history
Fixes bug with Popover and multiple tables on the same page
  • Loading branch information
IvanJosipovic committed Dec 4, 2019
1 parent 8b8dd21 commit 26d9b4d
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/BlazorTable/Components/Column.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@typeparam TableItem

<CascadingValue Value="(IColumn<TableItem>)this" Name="Column">
<Popover Target="@($"Filter-{Title}")" IsOpen="@FilterOpen" Placement="Placement.Bottom" DismissOnNextClick="false">
<Popover Reference="@this.FilterRef" IsOpen="@FilterOpen" Placement="Placement.Bottom" DismissOnNextClick="false">
<h3 class="popover-header">Filter</h3>
<div class="popover-body">

Expand Down
2 changes: 2 additions & 0 deletions src/BlazorTable/Components/Column.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public string Title

public Type Type { get; private set; }

public ElementReference FilterRef { get; set; }

public IFilter<TableItem> FilterControl { get; set; }

public void Dispose()
Expand Down
4 changes: 2 additions & 2 deletions src/BlazorTable/Components/Popover.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public bool? IsOpen
public Placement Placement { get; set; } = Placement.Auto;

[Parameter]
public string Target { get; set; }
public ElementReference Reference { get; set; }

[Parameter]
public RenderFragment ChildContent { get; set; }
Expand Down Expand Up @@ -75,7 +75,7 @@ protected override void OnAfterRender(bool firstrun)
if (IsOpen ?? false)
{
var placement = Placement.ToDescriptionString();
JSRuntime.InvokeVoidAsync("BlazorTablePopper", Target, MyRef, Arrow, placement);
JSRuntime.InvokeVoidAsync("BlazorTablePopper", Reference, MyRef, Arrow, placement);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/BlazorTable/Components/Table.razor
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@if (column.Filterable)
{
<div class="float-right">
<a href="javascript:;" id="@($"Filter-{column.Title}")" @onclick="@((x) => column.ToggleFilter())" style="text-decoration: none"><span style="@(column.Filter == null ? "opacity: 0.2;" : string.Empty)">&#128269;</span></a>
<a href="javascript:;" @ref="column.FilterRef" id="@($"Filter-{column.Title}")" @onclick="@((x) => column.ToggleFilter())" style="text-decoration: none"><span style="@(column.Filter == null ? "opacity: 0.2;" : string.Empty)">&#128269;</span></a>
</div>
}
</th>
Expand Down
5 changes: 5 additions & 0 deletions src/BlazorTable/Interfaces/IColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,10 @@ public interface IColumn<TableItem>
/// Horizontal alignment
/// </summary>
Align Align { get; set; }

/// <summary>
/// Filter Icon Element
/// </summary>
ElementReference FilterRef { get; set; }
}
}
4 changes: 1 addition & 3 deletions src/BlazorTable/wwwroot/BlazorTable.min.js

Large diffs are not rendered by default.

0 comments on commit 26d9b4d

Please sign in to comment.