Skip to content

Fix Blazor re-initialisation, duplicate Bootstrap CSS and sidebar a11y (0.4.1) - #2

Merged
puikinsh merged 1 commit into
mainfrom
fix/blazor-init-2026-11
Nov 30, 2026
Merged

puikinsh merged 1 commit into
mainfrom
fix/blazor-init-2026-11

Conversation

@puikinsh

Copy link
Copy Markdown
Member

Problems fixed

  • Nothing re-initialised after Blazor took over the page. adminlte-blazor.js called adminlte.Treeview.init, PushMenu.init and CardWidget.init. None of these exist in AdminLTE 4, so the calls did nothing. As a result, on aspnet.adminlte.io at phone width, tapping outside the open sidebar did not close it. The glue now calls adminlte.initialize(), which removes the previous run's listeners before running again. It also recreates the sidebar's OverlayScrollbars instance when a DOM patch has removed it.
  • Static pages lost AdminLTE's setup on navigation. <AdminLteScripts /> now loads the glue as a module, which re-runs the setup on Blazor's enhancedload event.
  • Clicks on href="#" toggles could go to the home page. With blazor.web.js loaded first, Blazor turned these clicks into navigation to /. The docs and demo now load <AdminLteScripts /> first, and the topbar user-menu toggle is now a <button>.
  • The sidebar stayed open after navigating on a phone. DashboardLayout now closes it after an interactive navigation.
  • Bootstrap's CSS was downloaded twice. <adminlte-styles> and <AdminLteStyles /> no longer link bootstrap.min.css; adminlte.min.css already contains Bootstrap.
  • Sidebar accessibility. role="menu" is removed, matching AdminLTE 4.10.3. The current link now gets aria-current="page".
  • The README menu example threw an exception. It named a RequireAdmin policy without registering it; the example now registers it.

The bundle moves to AdminLTE 4.10.3 and the version to 0.4.1.

Tests

All run on the .NET 10 SDK with Playwright (Chromium).

Demo (interactive server):

  • Phone width:
    • Tapping outside the sidebar closes it, both on first load and after interactive navigation.
    • The sidebar closes after navigating from it.
  • Desktop:
    • Treeview groups open and close.
    • A group click on /widgets/small-boxes stays on that page.
    • Push-menu collapse and expand work.
  • Throughout: one skip-link block, the OverlayScrollbars viewport present, no role="menu", no bootstrap.min.css, and no JS errors.

Static SSR app (dotnet new blazor -int None + DashboardLayout):

  • With the new script order:
    • Group and user-menu clicks on /reports/sales stay on the page.
    • After an enhanced navigation, the scrollbar and overlay come back, and tapping outside closes the sidebar on a phone.
  • With the old order (scripts after blazor.web.js), the same group click navigates to /, which reproduces the bug.

MVC app using the Tag Helpers:

  • Styling is unchanged without bootstrap.min.css.
  • The phone overlay closes the sidebar.
  • aria-current is rendered and role="menu" is gone.

Build and package:

  • dotnet build -c Release: 0 errors; the one warning (IL2026) was already there.
  • dotnet pack produces 0.4.1.

🤖 Generated with Claude Code

…p CSS; 0.4.1

- adminlte-blazor.js called Treeview/PushMenu/CardWidget.init, which don't exist in
  AdminLTE 4, so nothing re-initialised after Blazor replaced the prerendered layout
  (on phones the sidebar overlay no longer closed the sidebar). Use
  adminlte.initialize() and recreate a stale OverlayScrollbars instance.
- DashboardLayout runs the setup once after the first interactive render, restores
  the scrollbar on later renders, and closes the sidebar after navigation on phones.
- <AdminLteScripts /> loads adminlte-blazor.js as a module that re-runs the setup on
  Blazor's enhancedload event (statically rendered pages).
- Load <AdminLteScripts /> before blazor.web.js (docs, demo) so href="#" toggles are
  not turned into navigation to "/"; the topbar user menu toggle is a button.
- <adminlte-styles>/<AdminLteStyles /> no longer link bootstrap.min.css: adminlte.css
  already contains Bootstrap.
- Sidebar: drop role="menu", add aria-current="page" on the current link.
- README/NUGET: register the RequireAdmin policy the menu example uses.
- Bundle AdminLTE 4.10.3. Version 0.4.1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@puikinsh
puikinsh merged commit 4d45d5c into main Nov 30, 2026
1 check passed
@puikinsh
puikinsh deleted the fix/blazor-init-2026-11 branch November 30, 2026 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant