Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add StickyActionBar to web app in order to always show submit/cancel buttons in Item AddEdit.razor (#1629)
Leendert de Borst1db8ac788e16
diff --git a/apps/server/AliasVault.Client/Main/Pages/Items/AddEdit.razor b/apps/server/AliasVault.Client/Main/Pages/Items/AddEdit.razorindex 5f078ddae..8dd68d9bd 100644--- a/apps/server/AliasVault.Client/Main/Pages/Items/AddEdit.razor+++ b/apps/server/AliasVault.Client/Main/Pages/Items/AddEdit.razor@@ -418,6 +418,11 @@ else</div><button type="submit" class="hidden">@Localizer["SaveItemButton"]</button></EditForm>++ <StickyActionBar>+ <ConfirmButton OnClick="TriggerFormSubmit">@Localizer["SaveItemButton"]</ConfirmButton>+ <CancelButton OnClick="Cancel">@SharedLocalizer["Cancel"]</CancelButton>+ </StickyActionBar>}@code {diff --git a/apps/server/AliasVault.Client/_Imports.razor b/apps/server/AliasVault.Client/_Imports.razorindex 5c1416c7b..62cc64016 100644--- a/apps/server/AliasVault.Client/_Imports.razor+++ b/apps/server/AliasVault.Client/_Imports.razor@@ -33,6 +33,7 @@@using AliasVault.RazorComponents.Headings@using AliasVault.RazorComponents.Models@using AliasVault.RazorComponents.Paginators+@using AliasVault.RazorComponents.Layout@using Microsoft.AspNetCore.Components.Authorization@using Microsoft.AspNetCore.Components.WebAssembly.Authentication@using Blazored.LocalStoragediff --git a/apps/server/Shared/AliasVault.RazorComponents/Layout/StickyActionBar.razor b/apps/server/Shared/AliasVault.RazorComponents/Layout/StickyActionBar.razornew file mode 100644index 000000000..daeef1f7c--- /dev/null+++ b/apps/server/Shared/AliasVault.RazorComponents/Layout/StickyActionBar.razor@@ -0,0 +1,93 @@+@* StickyActionBar component - provides a fixed action bar at the bottom of the viewport *@+@* Only appears when user has scrolled down past a threshold or page is scrollable *@+@inject IJSRuntime JSRuntime+@implements IAsyncDisposable++<div class="sticky-action-bar-wrapper" style="display: none;">+ @* Spacer div to prevent content from being hidden behind the fixed bar *@+ <div class="h-20"></div>++ @* Fixed action bar *@+ <div class="fixed bottom-0 left-0 right-0 z-40 bg-white dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700 shadow-lg">+ <div class="max-w-screen-2xl mx-auto px-4 py-3">+ <div class="flex flex-wrap items-center justify-end gap-2">+ @ChildContent+ </div>+ </div>+ </div>+</div>++@code {+ /// <summary>+ /// Gets or sets the content to be displayed inside the sticky action bar.+ /// Typically contains buttons like Save and Cancel.+ /// </summary>+ [Parameter]+ public RenderFragment? ChildContent { get; set; }++ /// <summary>+ /// Gets or sets the scroll threshold in pixels before showing the bar.+ /// Default is 75 pixels.+ /// </summary>+ [Parameter]+ public int ScrollThreshold { get; set; } = 75;++ /// <inheritdoc />+ protected override async Task OnAfterRenderAsync(bool firstRender)+ {+ if (firstRender)+ {+ await JSRuntime.InvokeVoidAsync("eval", $@"+ (function() {{+ if (window._stickyBarCleanup) {{+ window._stickyBarCleanup();+ }}++ const threshold = {ScrollThreshold};++ function checkScroll() {{+ const scrollY = window.scrollY || document.documentElement.scrollTop;+ const docHeight = document.documentElement.scrollHeight;+ const viewHeight = window.innerHeight;+ const canScroll = docHeight > viewHeight + 50;+ const shouldShow = canScroll && scrollY > threshold;++ const bar = document.querySelector('.sticky-action-bar-wrapper');+ if (bar) {{+ bar.style.display = shouldShow ? 'block' : 'none';+ }}+ }}++ window.addEventListener('scroll', checkScroll);+ window.addEventListener('resize', checkScroll);++ window._stickyBarCleanup = function() {{+ window.removeEventListener('scroll', checkScroll);+ window.removeEventListener('resize', checkScroll);+ }};++ // Initial check after a small delay to ensure DOM is ready+ setTimeout(checkScroll, 100);+ }})();+ ");+ }+ }++ /// <inheritdoc />+ public async ValueTask DisposeAsync()+ {+ try+ {+ await JSRuntime.InvokeVoidAsync("eval", @"+ if (window._stickyBarCleanup) {+ window._stickyBarCleanup();+ window._stickyBarCleanup = null;+ }+ ");+ }+ catch+ {+ // Ignore errors during disposal+ }+ }+}diff --git a/apps/server/Shared/AliasVault.RazorComponents/_Imports.razor b/apps/server/Shared/AliasVault.RazorComponents/_Imports.razorindex d6862780f..56241f7c3 100644--- a/apps/server/Shared/AliasVault.RazorComponents/_Imports.razor+++ b/apps/server/Shared/AliasVault.RazorComponents/_Imports.razor@@ -1,3 +1,4 @@@using AliasVault.RazorComponents.Models@using AliasVault.RazorComponents.Tables@using Microsoft.AspNetCore.Components.Web+@using Microsoft.JSInterop