diff --git a/blazorbootstrap/Components/Alert/Alert.razor.cs b/blazorbootstrap/Components/Alert/Alert.razor.cs
index 35b67fc4d..787724b1d 100644
--- a/blazorbootstrap/Components/Alert/Alert.razor.cs
+++ b/blazorbootstrap/Components/Alert/Alert.razor.cs
@@ -48,7 +48,7 @@ protected override async Task OnInitializedAsync()
objRef ??= DotNetObjectReference.Create(this);
await base.OnInitializedAsync();
- QueueAfterRenderAction(async () => { await JS.InvokeVoidAsync("window.blazorBootstrap.alert.initialize", ElementId, objRef); });
+ QueueAfterRenderAction(async () => await JS.InvokeVoidAsync("window.blazorBootstrap.alert.initialize", ElementId, objRef), new RenderPriority());
}
[JSInvokable]
diff --git a/blazorbootstrap/Components/Button/Button.razor.cs b/blazorbootstrap/Components/Button/Button.razor.cs
index e7898eef7..3148e7a04 100644
--- a/blazorbootstrap/Components/Button/Button.razor.cs
+++ b/blazorbootstrap/Components/Button/Button.razor.cs
@@ -103,7 +103,7 @@ protected override void OnInitialized()
base.OnInitialized();
- if (!string.IsNullOrWhiteSpace(TooltipTitle)) QueueAfterRenderAction(async () => { await JS.InvokeVoidAsync("window.blazorBootstrap.tooltip.initialize", ElementRef); });
+ if (!string.IsNullOrWhiteSpace(TooltipTitle)) QueueAfterRenderAction(async () => await JS.InvokeVoidAsync("window.blazorBootstrap.tooltip.initialize", ElementRef), new RenderPriority());
}
protected override async Task OnParametersSetAsync()
diff --git a/blazorbootstrap/Components/Collapse/Collapse.razor.cs b/blazorbootstrap/Components/Collapse/Collapse.razor.cs
index d26046794..d05ed1cf6 100644
--- a/blazorbootstrap/Components/Collapse/Collapse.razor.cs
+++ b/blazorbootstrap/Components/Collapse/Collapse.razor.cs
@@ -46,7 +46,7 @@ protected override async Task OnInitializedAsync()
{
objRef ??= DotNetObjectReference.Create(this);
- QueueAfterRenderAction(async () => { await JS.InvokeVoidAsync("window.blazorBootstrap.collapse.initialize", ElementId, Parent, Toggle, objRef); });
+ QueueAfterRenderAction(async () => await JS.InvokeVoidAsync("window.blazorBootstrap.collapse.initialize", ElementId, Parent, Toggle, objRef), new RenderPriority());
await base.OnInitializedAsync();
}
diff --git a/blazorbootstrap/Components/Core/BlazorBootstrapComponentBase.cs b/blazorbootstrap/Components/Core/BlazorBootstrapComponentBase.cs
index 493ece045..7887643ca 100644
--- a/blazorbootstrap/Components/Core/BlazorBootstrapComponentBase.cs
+++ b/blazorbootstrap/Components/Core/BlazorBootstrapComponentBase.cs
@@ -55,7 +55,7 @@ public abstract class BlazorBootstrapComponentBase : ComponentBase, IDisposable,
///
/// A stack of functions to execute after the rendering.
///
- private Queue>? renderQueue;
+ private PriorityQueue, RenderPriority>? renderQueue;
#endregion
@@ -248,10 +248,11 @@ protected virtual ValueTask DisposeAsync(bool disposing)
/// Pushes an action to the stack to be executed after the rendering is done.
///
///
- protected void QueueAfterRenderAction(Func action)
+ ///
+ protected void QueueAfterRenderAction(Func action, RenderPriority renderPriority)
{
- renderQueue ??= new Queue>();
- renderQueue.Enqueue(action);
+ renderQueue ??= new PriorityQueue, RenderPriority>();
+ renderQueue.Enqueue(action, renderPriority);
}
#endregion
@@ -385,6 +386,6 @@ public string? StyleNames
return styleNames;
}
}
-
+
#endregion
}
diff --git a/blazorbootstrap/Components/Dropdown/Dropdown.razor.cs b/blazorbootstrap/Components/Dropdown/Dropdown.razor.cs
index f5b7d0a5d..1b46ca67f 100644
--- a/blazorbootstrap/Components/Dropdown/Dropdown.razor.cs
+++ b/blazorbootstrap/Components/Dropdown/Dropdown.razor.cs
@@ -46,7 +46,7 @@ protected override void OnInitialized()
base.OnInitialized();
- QueueAfterRenderAction(async () => { await JS.InvokeVoidAsync("window.blazorBootstrap.dropdown.initialize", ElementId, objRef); });
+ QueueAfterRenderAction(async () => await JS.InvokeVoidAsync("window.blazorBootstrap.dropdown.initialize", ElementId, objRef), new RenderPriority());
}
[JSInvokable]
diff --git a/blazorbootstrap/Components/Form/AutoComplete/AutoComplete.razor.cs b/blazorbootstrap/Components/Form/AutoComplete/AutoComplete.razor.cs
index 82dde2135..455d8a0f8 100644
--- a/blazorbootstrap/Components/Form/AutoComplete/AutoComplete.razor.cs
+++ b/blazorbootstrap/Components/Form/AutoComplete/AutoComplete.razor.cs
@@ -66,7 +66,7 @@ protected override async Task OnInitializedAsync()
await base.OnInitializedAsync();
- QueueAfterRenderAction(async () => { await JS.InvokeVoidAsync("window.blazorBootstrap.autocomplete.initialize", ElementRef, objRef); });
+ QueueAfterRenderAction(async () => await JS.InvokeVoidAsync("window.blazorBootstrap.autocomplete.initialize", ElementRef, objRef), new RenderPriority());
}
[JSInvokable]
diff --git a/blazorbootstrap/Components/Modals/Modal.razor.cs b/blazorbootstrap/Components/Modals/Modal.razor.cs
index a17bcf6a3..66c88bd13 100644
--- a/blazorbootstrap/Components/Modals/Modal.razor.cs
+++ b/blazorbootstrap/Components/Modals/Modal.razor.cs
@@ -72,7 +72,7 @@ protected override async Task OnInitializedAsync()
objRef ??= DotNetObjectReference.Create(this);
await base.OnInitializedAsync();
- QueueAfterRenderAction(async () => { await JS.InvokeVoidAsync("window.blazorBootstrap.modal.initialize", ElementId, UseStaticBackdrop, CloseOnEscape, objRef); });
+ QueueAfterRenderAction(async () => await JS.InvokeVoidAsync("window.blazorBootstrap.modal.initialize", ElementId, UseStaticBackdrop, CloseOnEscape, objRef), new RenderPriority());
}
[JSInvokable]
diff --git a/blazorbootstrap/Components/Offcanvas/Offcanvas.razor.cs b/blazorbootstrap/Components/Offcanvas/Offcanvas.razor.cs
index b86e77386..1a0c88f80 100644
--- a/blazorbootstrap/Components/Offcanvas/Offcanvas.razor.cs
+++ b/blazorbootstrap/Components/Offcanvas/Offcanvas.razor.cs
@@ -56,7 +56,7 @@ protected override async Task OnInitializedAsync()
objRef ??= DotNetObjectReference.Create(this);
await base.OnInitializedAsync();
- QueueAfterRenderAction(async () => { await JS.InvokeVoidAsync("window.blazorBootstrap.offcanvas.initialize", ElementId, UseStaticBackdrop, CloseOnEscape, IsScrollable, objRef); });
+ QueueAfterRenderAction(async () => await JS.InvokeVoidAsync("window.blazorBootstrap.offcanvas.initialize", ElementId, UseStaticBackdrop, CloseOnEscape, IsScrollable, objRef), new RenderPriority());
}
[JSInvokable]
diff --git a/blazorbootstrap/Components/PdfViewer/PdfViewer.razor.cs b/blazorbootstrap/Components/PdfViewer/PdfViewer.razor.cs
index 6d2b58b70..653a1cfce 100644
--- a/blazorbootstrap/Components/PdfViewer/PdfViewer.razor.cs
+++ b/blazorbootstrap/Components/PdfViewer/PdfViewer.razor.cs
@@ -28,7 +28,7 @@ protected override async Task OnInitializedAsync()
objRef ??= DotNetObjectReference.Create(this);
await base.OnInitializedAsync();
- QueueAfterRenderAction(async () => await PdfViewerJsInterop.InitializeAsync(objRef!, ElementId!, scale, rotation, Url!));
+ QueueAfterRenderAction(async () => await PdfViewerJsInterop.InitializeAsync(objRef!, ElementId!, scale, rotation, Url!), new RenderPriority());
}
[JSInvokable]
diff --git a/blazorbootstrap/Components/ScriptLoader/ScriptLoader.razor.cs b/blazorbootstrap/Components/ScriptLoader/ScriptLoader.razor.cs
index e8c1adc81..0f5a9111c 100644
--- a/blazorbootstrap/Components/ScriptLoader/ScriptLoader.razor.cs
+++ b/blazorbootstrap/Components/ScriptLoader/ScriptLoader.razor.cs
@@ -25,7 +25,7 @@ protected override async Task OnInitializedAsync()
{
objRef ??= DotNetObjectReference.Create(this);
- QueueAfterRenderAction(async () => { await JS.InvokeVoidAsync("window.blazorBootstrap.scriptLoader.initialize", ElementId, Async, ScriptId, Source, type, objRef); });
+ QueueAfterRenderAction(async () => await JS.InvokeVoidAsync("window.blazorBootstrap.scriptLoader.initialize", ElementId, Async, ScriptId, Source, type, objRef), new RenderPriority());
await base.OnInitializedAsync();
}
diff --git a/blazorbootstrap/Components/Sidebar/Sidebar.razor.cs b/blazorbootstrap/Components/Sidebar/Sidebar.razor.cs
index 168593138..057a824b7 100644
--- a/blazorbootstrap/Components/Sidebar/Sidebar.razor.cs
+++ b/blazorbootstrap/Components/Sidebar/Sidebar.razor.cs
@@ -48,7 +48,7 @@ protected override async Task OnInitializedAsync()
await base.OnInitializedAsync();
- QueueAfterRenderAction(async () => { await JS.InvokeVoidAsync("window.blazorBootstrap.sidebar.initialize", ElementId, objRef); });
+ QueueAfterRenderAction(async () => await JS.InvokeVoidAsync("window.blazorBootstrap.sidebar.initialize", ElementId, objRef), new RenderPriority());
}
[JSInvokable]
diff --git a/blazorbootstrap/Components/Tabs/Tabs.razor.cs b/blazorbootstrap/Components/Tabs/Tabs.razor.cs
index 259c1a26d..c6b9d36b5 100644
--- a/blazorbootstrap/Components/Tabs/Tabs.razor.cs
+++ b/blazorbootstrap/Components/Tabs/Tabs.razor.cs
@@ -55,7 +55,7 @@ protected override async Task OnInitializedAsync()
await base.OnInitializedAsync();
- QueueAfterRenderAction(async () => { await JS.InvokeVoidAsync("window.blazorBootstrap.tabs.initialize", ElementId, objRef); });
+ QueueAfterRenderAction(async () => await JS.InvokeVoidAsync("window.blazorBootstrap.tabs.initialize", ElementId, objRef), new RenderPriority());
}
[JSInvokable]
@@ -118,7 +118,8 @@ public void InitializeRecentTab(bool showTab)
if (showTab)
await ShowTabAsync(tab);
}
- }
+ },
+ new RenderPriority()
);
}
diff --git a/blazorbootstrap/Components/Toasts/SimpleToast.razor.cs b/blazorbootstrap/Components/Toasts/SimpleToast.razor.cs
index eac84588d..5ada3c5e5 100644
--- a/blazorbootstrap/Components/Toasts/SimpleToast.razor.cs
+++ b/blazorbootstrap/Components/Toasts/SimpleToast.razor.cs
@@ -41,7 +41,7 @@ protected override async Task OnInitializedAsync()
await base.OnInitializedAsync();
- QueueAfterRenderAction(async () => { await ShowAsync(); });
+ QueueAfterRenderAction(async () => await ShowAsync(), new RenderPriority());
}
[JSInvokable]
diff --git a/blazorbootstrap/Components/Toasts/Toast.razor.cs b/blazorbootstrap/Components/Toasts/Toast.razor.cs
index 404b26103..247f87378 100644
--- a/blazorbootstrap/Components/Toasts/Toast.razor.cs
+++ b/blazorbootstrap/Components/Toasts/Toast.razor.cs
@@ -78,7 +78,7 @@ protected override async Task OnInitializedAsync()
objRef ??= DotNetObjectReference.Create(this);
await base.OnInitializedAsync();
- QueueAfterRenderAction(async () => { await ShowAsync(); });
+ QueueAfterRenderAction(async () => await ShowAsync(), new RenderPriority());
}
[JSInvokable]
diff --git a/blazorbootstrap/Components/Tooltip/Tooltip.razor.cs b/blazorbootstrap/Components/Tooltip/Tooltip.razor.cs
index f7de572a6..6621c6df8 100644
--- a/blazorbootstrap/Components/Tooltip/Tooltip.razor.cs
+++ b/blazorbootstrap/Components/Tooltip/Tooltip.razor.cs
@@ -50,7 +50,7 @@ protected override async Task OnInitializedAsync()
await base.OnInitializedAsync();
- QueueAfterRenderAction(async () => { await JS.InvokeVoidAsync("window.blazorBootstrap.tooltip.initialize", ElementRef); });
+ QueueAfterRenderAction(async () => await JS.InvokeVoidAsync("window.blazorBootstrap.tooltip.initialize", ElementRef), new RenderPriority());
}
protected override async Task OnParametersSetAsync()
diff --git a/blazorbootstrap/Enums/Priority.cs b/blazorbootstrap/Enums/Priority.cs
new file mode 100644
index 000000000..e89143036
--- /dev/null
+++ b/blazorbootstrap/Enums/Priority.cs
@@ -0,0 +1,8 @@
+namespace BlazorBootstrap;
+
+public enum Priority
+{
+ High = 0,
+ Medium,
+ Low
+}
diff --git a/blazorbootstrap/Models/RenderPriority.cs b/blazorbootstrap/Models/RenderPriority.cs
new file mode 100644
index 000000000..c9554294f
--- /dev/null
+++ b/blazorbootstrap/Models/RenderPriority.cs
@@ -0,0 +1,19 @@
+namespace BlazorBootstrap;
+
+public record RenderPriority
+{
+ public RenderPriority()
+ {
+ Priority = Priority.Low;
+ Order = DateTime.Now.Ticks;
+ }
+
+ public RenderPriority(Priority priority)
+ {
+ Priority = priority;
+ }
+
+ public Priority Priority { get; init; }
+
+ public long Order { get; init; }
+}