File tree Expand file tree Collapse file tree
TestApps/BlazorDialog.TestAppsCommon Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212 <Copyright />
1313 <PackageTags >blazor blazor-component blazor-dialog dialog modal blazor-modal blazordialog blazormodaldialog blazormodal razor razor-components razorcomponents</PackageTags >
1414 <VersionSuffix >$(VersionSuffix)</VersionSuffix >
15- <Version >3.0 .0</Version >
15+ <Version >3.1 .0</Version >
1616 <Version Condition =" '$(VersionSuffix)' != '' " >$(Version)-$(VersionSuffix)</Version >
1717 <Product >BlazorDialog</Product >
1818 </PropertyGroup >
Original file line number Diff line number Diff line change 105105 /// </summary >
106106 [Parameter ] public bool PreventNavigation { get ; set ; } = true ;
107107
108+ private bool ? _forcedPreventNavigation ;
108109 protected TaskCompletionSource <object > taskCompletionSource ;
109110 internal Action <object > OnDialogHide ;
110111 protected void NotifyDialogHidden (object result ) => OnDialogHide ? .Invoke (result );
305306 return this .isShowing ;
306307 }
307308
309+ internal bool GetPreventNavigation ()
310+ {
311+ if (_forcedPreventNavigation .HasValue ) return _forcedPreventNavigation .Value ;
312+ return this .PreventNavigation ;
313+ }
314+
315+ /// <summary >
316+ /// Forces the dialog to allow navigation when shown, regardless of the <see cref =" PreventNavigation" /> property.
317+ /// </summary >
318+ public void ForceAllowNavigation ()
319+ {
320+ _forcedPreventNavigation = false ;
321+ }
322+
323+ /// <summary >
324+ /// Forces the dialog to prevent navigation when shown, regardless of the <see cref =" PreventNavigation" /> property.
325+ /// </summary >
326+ public void ForcePreventNavigation ()
327+ {
328+ _forcedPreventNavigation = true ;
329+ }
308330
309331 protected override Task OnAfterRenderAsync (bool firstRender )
310332 {
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ public void RegisterLocationChangingHandler(Dialog dialog)
3434
3535 private ValueTask OnLocationChanging ( LocationChangingContext context )
3636 {
37- if ( ! context . IsNavigationIntercepted && _dialogsStack . Any ( x => x . PreventNavigation ) )
37+ if ( ! context . IsNavigationIntercepted && _dialogsStack . Any ( x => x . GetPreventNavigation ( ) ) )
3838 {
3939 context . PreventNavigation ( ) ;
4040 }
Original file line number Diff line number Diff line change @@ -81,7 +81,14 @@ Make sure that there is a call to `app.UseStaticFiles();` in your server project
8181 </details>
8282
8383## Release Notes
84- <details open =" open " ><summary >3.0</summary >
84+
85+ <details open =" open " ><summary >3.1</summary >
86+
87+ > - Added ` ForceAllowNavigation ` and ` ForcePreventNavigation ` methods to the ` Dialog ` component to allow/prevent navigation regardless of the ` PreventNavigation ` parameter.
88+ </details>
89+
90+
91+ <details ><summary >3.0</summary >
8592
8693> - Migrate to .NET 8.0
8794> - Add PreventNavigation option to prevent navigation when dialog is open.
Original file line number Diff line number Diff line change 2323 <option value =" @DialogAnimation.Zoom" >@DialogAnimation.Zoom </option >
2424 <option value =" @DialogAnimation.FadeIn" >@DialogAnimation.FadeIn </option >
2525</select >
26- <Dialog Id =" simple-large-dialog" Size =" size" Centered =" isCentered" Animation =" animation" CssClass =" custom-class" >
26+ <Dialog Id =" simple-large-dialog" Size =" size" Centered =" isCentered" Animation =" animation" CssClass =" custom-class" @ref = " simpleLargeDialog " >
2727 <DialogInputProvider TInput =" string" >
2828 <DialogHeader ShowClose =" true" >
2929 <h4 >@context.Input </h4 >
128128
129129<button @onclick =" SimpleDialogOnClick" >Simple Dialog</button >
130130<button @onclick =" SimpleDialogBigOnClick" >Simple Dialog Big</button >
131+ <button @onclick =" SimpleLargeDialogDisablePreventNavigation" >Simple Dialog Big allow navigation</button >
131132
132133@if (dialogResult != null )
133134{
139140 bool isCentered ;
140141 DialogSize size ;
141142 DialogAnimation animation ;
143+ Dialog simpleLargeDialog ;
142144
143145 async Task SimpleDialogOnClick ()
144146 {
149151 {
150152 dialogResult = await dialogService .ShowDialog <string >(" simple-large-dialog" , " (Simple Dialog Large) Are you sure?" );
151153 }
154+
155+ void SimpleLargeDialogDisablePreventNavigation ()
156+ {
157+ simpleLargeDialog .ForceAllowNavigation ();
158+ }
152159}
You can’t perform that action at this time.
0 commit comments