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:
@@ -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
|
/* Grand livre / Dashboard switcher, top-right of both pages. Only present
|
||||||
on those two custom routes, but attached here (already loaded on every
|
on those two custom routes, but attached here rather than duplicated
|
||||||
page for the phantom-top-bar fix above) rather than duplicated between
|
between home.css and dashboard.css -- and defined with its own explicit
|
||||||
home.css and dashboard.css -- and defined with its own explicit colors
|
colors rather than relying on either page's #figli-*-app-scoped custom
|
||||||
rather than relying on either page's #figli-*-app-scoped custom
|
|
||||||
properties, since this <nav> sits outside both of those elements. */
|
properties, since this <nav> sits outside both of those elements. */
|
||||||
.figli-page-nav {
|
.figli-page-nav {
|
||||||
display: flex;
|
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:
|
dependencies:
|
||||||
- core/drupal
|
- core/drupal
|
||||||
|
|
||||||
hide_admin_sidebar:
|
hide_admin_chrome:
|
||||||
css:
|
css:
|
||||||
theme:
|
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().
|
* Implements hook_page_attachments().
|
||||||
*
|
*
|
||||||
* Core Navigation's top bar renders empty (whitespace-only regions defeat
|
* The admin top bar and sidebar (Gin/core Navigation chrome) are only
|
||||||
* its own :not(:empty) visibility check) on every page, not just admin
|
* hidden on this module's own front-end pages -- real Drupal admin pages
|
||||||
* routes -- attach the fix globally rather than per-route.
|
* (/admin/*, node edit forms, etc.) keep them, since Gin puts the page's
|
||||||
*
|
* local actions (Save included) inside the top bar there. Route-scoped
|
||||||
* The admin sidebar itself (#admin-toolbar) is only hidden on this
|
* rather than folded into the always-on admin_chrome attachment below.
|
||||||
* 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.
|
|
||||||
*/
|
*/
|
||||||
function figli_compta_ledger_page_attachments(array &$attachments) {
|
function figli_compta_ledger_page_attachments(array &$attachments) {
|
||||||
$attachments['#attached']['library'][] = 'figli_compta_ledger/admin_chrome';
|
$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',
|
'figli_compta_ledger.link_entree',
|
||||||
];
|
];
|
||||||
if (in_array(\Drupal::routeMatch()->getRouteName(), $front_end_routes, TRUE)) {
|
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';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user