Skip to content

Commit

Permalink
Fixed DataGrid inner filter popups not closed properly
Browse files Browse the repository at this point in the history
  • Loading branch information
enchev committed Jul 31, 2023
1 parent 4b3a7af commit c2f0422
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
2 changes: 2 additions & 0 deletions Radzen.Blazor/RadzenDataGrid.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,7 @@ public async Task ClearFilter(RadzenDataGridColumn<TItem> column, bool closePopu
else
{
await JSRuntime.InvokeVoidAsync("Radzen.closePopup", $"{PopupID}{column.GetFilterProperty()}");
await JSRuntime.InvokeVoidAsync("Radzen.closeAllPopups", $"{PopupID}{column.GetFilterProperty()}");
}
}

Expand Down Expand Up @@ -752,6 +753,7 @@ public async Task ApplyFilter(RadzenDataGridColumn<TItem> column, bool closePopu
else
{
await JSRuntime.InvokeVoidAsync("Radzen.closePopup", $"{PopupID}{column.GetFilterProperty()}");
await JSRuntime.InvokeVoidAsync("Radzen.closeAllPopups", $"{PopupID}{column.GetFilterProperty()}");
}
}
await OnFilter(new ChangeEventArgs() { Value = column.GetFilterValue() }, column, true);
Expand Down
32 changes: 17 additions & 15 deletions Radzen.Blazor/wwwroot/Radzen.Blazor.js
Original file line number Diff line number Diff line change
Expand Up @@ -842,24 +842,11 @@ window.Radzen = {
}
};

if (!Radzen.closeAllPopups) {
Radzen.closeAllPopups = function (e) {
for (var i = 0; i < Radzen.popups.length; i++) {
var p = Radzen.popups[i];

var closestPopup = e && e.target && e.target.closest && (e.target.closest('.rz-popup') || e.target.closest('.rz-overlaypanel'));
if (closestPopup && closestPopup != p) {
return;
}

Radzen.closePopup(p.id, p.instance, p.callback, e);
}
Radzen.popups = [];
};
if (!Radzen.popups) {
Radzen.popups = [];
}

Radzen.popups.push({id, instance, callback});
Radzen.popups.push({ id, instance, callback });

document.body.appendChild(popup);
document.removeEventListener('mousedown', Radzen[id]);
Expand All @@ -881,6 +868,21 @@ window.Radzen = {
document.addEventListener('contextmenu', Radzen[id]);
}
},
closeAllPopups: function (e, id) {
if (!Radzen.popups) return;
var el = e && e.target || id && documentElement.getElementById(id);
for (var i = 0; i < Radzen.popups.length; i++) {
var p = Radzen.popups[i];

var closestPopup = el && el.closest && (el.closest('.rz-popup') || el.closest('.rz-overlaypanel'));
if (closestPopup && closestPopup != p) {
return;
}

Radzen.closePopup(p.id, p.instance, p.callback, e);
}
Radzen.popups = [];
},
closePopup: function (id, instance, callback, e) {
var popup = document.getElementById(id);
if (!popup) return;
Expand Down

0 comments on commit c2f0422

Please sign in to comment.