Skip to content

Commit

Permalink
fix: fixed displaying delete popup msg
Browse files Browse the repository at this point in the history
Refs: BLOCKLY-T-2
  • Loading branch information
thelegendaryzubat committed Jan 18, 2022
1 parent e864a11 commit 6b90733
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Sitko.Blockly.MudBlazor/Forms/MudBlocklyForm.razor
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
</MudButton>
</span>
<span title="@LocalizationProvider["Delete block"]">
<MudPopover Disabled="!CanDeleteBlock(block)" Placement="@Placement.Left" Title="@LocalizationProvider["Delete block?"]"
OnConfirm="@(async () => await DeleteBlockAsync(block))"
OkText="@LocalizationProvider["Delete block"]"
CancelText="@LocalizationProvider["Cancel"]">

<MudPopover Open="@(_openBlockId==block.Id)" Fixed="true" Class="px-4 pt-4" Tag="block.Id">
<div class="d-flex flex-column">
<MudText>@LocalizationProvider["Delete block?"]</MudText>
<MudButton OnClick="@(async () => await DeleteBlockAsync(block))" Class="ml-auto mr-n3 mb-1" Color="Color.Error">@LocalizationProvider["Delete block"]</MudButton>
<MudButton OnClick="@(()=>ToggleOpen(block.Id))" Class="ml-auto mr-n3 mb-1" Color="Color.Error">@LocalizationProvider["Cancel"]</MudButton>
</div>
</MudPopover>

<MudButton Disabled="!CanDeleteBlock(block)" Size="Size.Medium">
<MudButton Disabled="!CanDeleteBlock(block)" Size="Size.Medium" OnClick="@(()=>ToggleOpen(block.Id))">
<MudIcon Icon="@Icons.Filled.Delete"></MudIcon>
</MudButton>
</span>
Expand Down
13 changes: 13 additions & 0 deletions src/Sitko.Blockly.MudBlazor/Forms/MudBlocklyForm.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public partial class MudBlocklyForm

[Parameter] public string? Label { get; set; }

private Guid? _openBlockId;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await base.OnAfterRenderAsync(firstRender);
Expand All @@ -20,4 +21,16 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
await ScriptInjector.InjectAsync(MudBlazorBlocklyModule.MudBlazorBlocklyCssRequest);
}
}
private void ToggleOpen(Guid blockId)
{
if (_openBlockId == blockId)
{
_openBlockId = null;
}
else
{
_openBlockId = blockId;
}
}

}

0 comments on commit 6b90733

Please sign in to comment.