Stop hiding the top bar globally -- it hid the Save button on entity edit forms

.top-bar was unconditionally hidden on every page (admin_chrome library)
on the assumption it always renders empty, which held on our own pages
but not on entity edit forms, where Gin puts the page's local actions --
Save included -- inside .top-bar. Folded it into the same route-scoped
library as the admin sidebar (renamed hide_admin_sidebar ->
hide_admin_chrome) so both are hidden only on our front-end routes and
real admin pages keep a working Save button.
This commit is contained in:
2026-09-05 17:01:39 +02:00
parent 73818779c1
commit 619a2ab70c
5 changed files with 39 additions and 43 deletions
@@ -1,23 +1,7 @@
/* Core Navigation's top bar (`.top-bar`) only shows itself when its
tools/context/actions regions are non-empty -- but with no blocks placed
there, the regions still contain whitespace text nodes from the Twig
loop scaffolding, which defeats the `:not(:empty)` check. Result: an
empty top bar renders anyway, with the page content pushed down to make
room for it. We only use the Gin sidebar (the left icon rail), so force
the phantom bar off and collapse the space it would otherwise reserve. */
.top-bar {
display: none !important;
}
.top-bar ~ .dialog-off-canvas-main-canvas {
margin-block-start: 0 !important;
}
/* Grand livre / Dashboard switcher, top-right of both pages. Only present
on those two custom routes, but attached here (already loaded on every
page for the phantom-top-bar fix above) rather than duplicated between
home.css and dashboard.css -- and defined with its own explicit colors
rather than relying on either page's #figli-*-app-scoped custom
on those two custom routes, but attached here rather than duplicated
between home.css and dashboard.css -- and defined with its own explicit
colors rather than relying on either page's #figli-*-app-scoped custom
properties, since this <nav> sits outside both of those elements. */
.figli-page-nav {
display: flex;
@@ -0,0 +1,28 @@
/* Only attached on this module's own front-end routes (see
figli_compta_ledger_page_attachments()) -- real Drupal admin pages
(/admin/*, node edit forms, etc.) keep all of this as normal.
Previously the top-bar rule below was unconditional (attached on every
page via admin_chrome), on the assumption that core Navigation's top
bar (`.top-bar`) always renders empty -- true on our own pages (no
blocks placed there, so whitespace text nodes from the Twig loop
scaffolding defeat its own `:not(:empty)` visibility check), but wrong
on entity edit forms, where Gin puts the page's local actions (the
Save button included) *inside* `.top-bar` -- hiding it there hid Save
itself, not just an empty bar. */
.top-bar {
display: none !important;
}
.top-bar ~ .dialog-off-canvas-main-canvas {
margin-block-start: 0 !important;
}
/* The core Navigation module's admin sidebar (#admin-toolbar, ~65px fixed
rail) + its collapsed-state control bar and overlay. */
#admin-toolbar,
.admin-toolbar-control-bar,
.admin-toolbar-overlay {
display: none !important;
}
.dialog-off-canvas-main-canvas {
margin-inline-start: 0 !important;
}
@@ -1,13 +0,0 @@
/* The core Navigation module's admin sidebar (#admin-toolbar, ~65px fixed
rail) + its collapsed-state control bar and overlay. Only attached on
this module's own front-end routes (see
figli_compta_ledger_page_attachments()) -- real Drupal admin pages
(/admin/*, node edit forms, etc.) keep the sidebar as normal. */
#admin-toolbar,
.admin-toolbar-control-bar,
.admin-toolbar-overlay {
display: none !important;
}
.dialog-off-canvas-main-canvas {
margin-inline-start: 0 !important;
}
@@ -34,7 +34,7 @@ admin_chrome:
dependencies:
- core/drupal
hide_admin_sidebar:
hide_admin_chrome:
css:
theme:
css/hide-admin-sidebar.css: {}
css/hide-admin-chrome.css: {}
@@ -219,14 +219,11 @@ function figli_compta_ledger_theme($existing, $type, $theme, $path) {
/**
* Implements hook_page_attachments().
*
* Core Navigation's top bar renders empty (whitespace-only regions defeat
* its own :not(:empty) visibility check) on every page, not just admin
* routes -- attach the fix globally rather than per-route.
*
* The admin sidebar itself (#admin-toolbar) is only hidden on this
* module's own front-end pages -- real Drupal admin pages (/admin/*, node
* edit forms, etc.) should keep it, so that one is route-scoped rather
* than folded into the always-on admin_chrome attachment above.
* The admin top bar and sidebar (Gin/core Navigation chrome) are only
* hidden on this module's own front-end pages -- real Drupal admin pages
* (/admin/*, node edit forms, etc.) keep them, since Gin puts the page's
* local actions (Save included) inside the top bar there. Route-scoped
* rather than folded into the always-on admin_chrome attachment below.
*/
function figli_compta_ledger_page_attachments(array &$attachments) {
$attachments['#attached']['library'][] = 'figli_compta_ledger/admin_chrome';
@@ -238,7 +235,7 @@ function figli_compta_ledger_page_attachments(array &$attachments) {
'figli_compta_ledger.link_entree',
];
if (in_array(\Drupal::routeMatch()->getRouteName(), $front_end_routes, TRUE)) {
$attachments['#attached']['library'][] = 'figli_compta_ledger/hide_admin_sidebar';
$attachments['#attached']['library'][] = 'figli_compta_ledger/hide_admin_chrome';
}
}