Skip to content

fix(layout): rebuild the control sidebar on Bootstrap Offcanvas - #11

Merged
puikinsh merged 1 commit into
masterfrom
fix/control-sidebar-offcanvas
Aug 11, 2026
Merged

fix(layout): rebuild the control sidebar on Bootstrap Offcanvas#11
puikinsh merged 1 commit into
masterfrom
fix/control-sidebar-offcanvas

Conversation

@puikinsh

Copy link
Copy Markdown
Member

Description

The control sidebar was AdminLTE 3 markup that survived the v4 rewrite. It never worked in this package.

What was wrong

control-sidebar appears zero times anywhere in AdminLTE 4 — not in dist/css/adminlte.css, not in dist/js/adminlte.js, not in src/scss/, in either 4.1.0 or 4.3.1. AdminLTE 3.2.0 still ships build/scss/_control-sidebar.scss; v4 has no equivalent and never mentions the component in its changelog. Three consequences:

  • No toggle handler. v4's supported data-lte-toggle values are card-collapse, card-maximize, card-remove, chat-pane, fullscreen, sidebar, sidebar-search, treeview. control-sidebar is not one, so the attribute bound to nothing. (chat-pane is unrelated — it toggles a .direct-chat contacts pane inside a card.)
  • No styles. .control-sidebar, .control-sidebar-dark and .control-sidebar-content have no rules at all, so control_sidebar_theme was inert too.
  • No grid area. v4's .app-wrapper is a CSS grid with exactly lte-app-sidebar, lte-app-header, lte-app-main and lte-app-footer.

So control_sidebar => true did not render a panel that failed to open — it auto-placed an unstyled, permanently visible block into the layout after the footer:

<footer class="app-footer small"></footer>
<aside class="control-sidebar control-sidebar-dark" data-lte-toggle="control-sidebar">
    <div class="control-sidebar-content"></div>
</aside>

Meanwhile docs/layout.md told you to toggle it with data-lte-toggle="control-sidebar", and nothing in the package rendered a button for it either way.

Default is false, so only users who enabled it were affected — but they got a layout glitch with no way to diagnose it.

The fix

Rebuilt on Bootstrap's Offcanvas, which is already imported by the published resources/js/adminlte.js (import 'bootstrap') and is position: fixed, so it stays out of the grid entirely. Backdrop, Esc-to-close and focus trap come for free — no custom CSS or JS.

  • #adminlte-control-sidebar, .offcanvas.offcanvas-end, labelled by its own title with a working close button.
  • Enabling control_sidebar now also renders the navbar gear toggle that was missing, so the panel can be opened at all.
  • control_sidebar_theme finally does something: applied as data-bs-theme on the panel.
  • Body content via @section('control_sidebar') or @push('control_sidebar'); $slot still honoured for direct includes.

The config API (control_sidebar, control_sidebar_theme) is unchanged.

Breaking change

If you styled the old .control-sidebar / .control-sidebar-dark / .control-sidebar-content classes yourself, retarget those rules at #adminlte-control-sidebar. Since those classes have never had any styles under v4, this is unlikely to affect anyone. Called out in CHANGELOG.md and docs/layout.md.

Tests

6 new tests in tests/ControlSidebarTest.php: renders nothing when disabled; offcanvas + navbar toggle appear together and point at the same element when enabled; theme maps to data-bs-theme; body accepts section / stack / slot content and escapes non-Htmlable slots; panel is labelled for assistive tech; and a regression guard asserting no v3 markup survives anywhere in the rendered page.

Checklist

  • composer check passes locally (Pint + PHPStan + PHPUnit) — 88 tests, 395 assertions
  • Added/updated tests for the change
  • Updated docs in docs/ if behaviour or APIs changed (they are served in-app at /docs)
  • Added a CHANGELOG.md entry under [Unreleased]
  • New translatable strings added to all 9 locale files in resources/lang/ — reuses the existing adminlte.settings key; parity verified at 0 missing across all 9

🤖 Generated with Claude Code

The partial was still emitting AdminLTE 3 markup — `.control-sidebar`,
`.control-sidebar-dark`, `.control-sidebar-content` and
`data-lte-toggle="control-sidebar"`. AdminLTE 4 dropped that component:
the string appears nowhere in 4.1 or 4.3, not in the CSS, the JS or the
SCSS source, and v4's `.app-wrapper` grid has no area for a right-hand
panel (3.2.0 still ships build/scss/_control-sidebar.scss, v4 has no
equivalent).

So `control_sidebar => true` did not render a panel that failed to open.
It auto-placed an unstyled, permanently visible block into the layout
grid after the footer, with nothing anywhere in the package able to open
or close it, while the docs told you to toggle it with an attribute that
has no handler. `control_sidebar_theme` was inert for the same reason.

Rebuilt on Bootstrap's Offcanvas, which is already imported by the
published resources/js/adminlte.js and brings the backdrop, Esc-to-close
and focus trap with it — no custom CSS or JS. Enabling the flag now also
renders the navbar gear button that was missing, so the panel can be
opened at all, and `control_sidebar_theme` maps to `data-bs-theme` on the
panel. The body takes @section('control_sidebar') or
@Push('control_sidebar'); `$slot` still works for direct includes.

Anyone who styled the old class names should retarget those rules at
`#adminlte-control-sidebar`, though nothing rendered before, so this is
unlikely to affect anyone.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@puikinsh
puikinsh merged commit afc76d7 into master Aug 11, 2026
3 checks passed
@puikinsh
puikinsh deleted the fix/control-sidebar-offcanvas branch August 11, 2026 14:17
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