File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
src/BootstrapBlazor/Components/Tab Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 166166
167167 RenderFragment RenderHeaderItem (TabItem item ) =>
168168 @<div @key =" @item" class =" @GetItemWrapClassString(item)" draggable =" @DraggableString" >
169- <a href =" @item.Url" role =" tab" tabindex =" -1" class =" @GetClassString(item)" @onclick =" @(() => OnClickTabItem(item))" @onclick:preventDefault =" @(!ClickTabToNavigation)" >
169+ <a href =" @item.Url" role =" tab" tabindex =" -1" class =" @GetClassString(item)"
170+ @oncontextmenu =" e => OnContextMenu(e, item)" @oncontextmenu:preventDefault =" IsPreventDefault"
171+ @onclick =" @(() => OnClickTabItem(item))" @onclick:preventDefault =" @(!ClickTabToNavigation)" >
170172 @RenderHeaderItemContent(item)
171173 </a >
172174 @if (TabStyle == TabStyle .Chrome )
Original file line number Diff line number Diff line change 33// See the LICENSE file in the project root for more information.
44// Maintainer: Argo Zhang([email protected] ) Website: https://www.blazor.zone 55
6+ using Microsoft . AspNetCore . Components . Web ;
67using Microsoft . Extensions . Localization ;
78using System . Collections . Concurrent ;
89using System . Reflection ;
@@ -370,6 +371,9 @@ public partial class Tab : IHandlerException
370371 [ Inject , NotNull ]
371372 private DialogService ? DialogService { get ; set ; }
372373
374+ [ CascadingParameter ]
375+ private ContextMenuZone ? ContextMenuZone { get ; set ; }
376+
373377 private ConcurrentDictionary < TabItem , bool > LazyTabCache { get ; } = new ( ) ;
374378
375379 private bool HandlerNavigation { get ; set ; }
@@ -382,6 +386,8 @@ public partial class Tab : IHandlerException
382386
383387 private readonly ConcurrentDictionary < TabItem , TabItemContent > _cache = [ ] ;
384388
389+ private bool IsPreventDefault => ContextMenuZone != null ;
390+
385391 /// <summary>
386392 /// <inheritdoc/>
387393 /// </summary>
@@ -965,4 +971,12 @@ protected override async ValueTask DisposeAsync(bool disposing)
965971 ErrorLogger ? . UnRegister ( this ) ;
966972 }
967973 }
974+
975+ private async Task OnContextMenu ( MouseEventArgs e , TabItem item )
976+ {
977+ if ( ContextMenuZone != null )
978+ {
979+ await ContextMenuZone . OnContextMenu ( e , item ) ;
980+ }
981+ }
968982}
You can’t perform that action at this time.
0 commit comments