fix: stabilize mobile admin navigation

dev
admin 2 months ago
parent 3aeeff22a7
commit 8b2cb35b58

@ -1,9 +1,24 @@
.admin-template-body {
--admin-viewport-height: 100vh;
min-height: 100vh;
min-height: 100dvh;
padding-bottom: 0 !important;
background: #f3f5f9;
}
@supports (height: 100dvh) {
.admin-template-body {
--admin-viewport-height: 100dvh;
}
}
.admin-template#app-layout {
min-height: 100vh;
min-height: 100dvh;
height: auto !important;
overflow: visible !important;
}
.admin-template .topbar-custom {
position: fixed;
top: 0;
@ -20,10 +35,10 @@
.admin-template .app-sidebar-menu {
position: fixed;
inset: 0 auto 0 0;
inset: 0 auto auto 0;
width: 260px;
height: 100vh;
height: 100dvh;
height: var(--admin-viewport-height, 100dvh);
padding-top: 0 !important;
z-index: 1001 !important;
background: #061836;
@ -45,6 +60,8 @@
}
.admin-template .content-page {
display: flex;
flex-direction: column;
min-height: 100vh;
min-height: 100dvh;
margin-left: 260px;
@ -53,6 +70,7 @@
}
.admin-template .content {
flex: 1 0 auto;
padding-bottom: 32px;
}
@ -2015,6 +2033,7 @@ body.billing-detail-open {
}
.admin-template .footer {
position: static;
margin-left: 0;
padding: 18px 0;
background: transparent;
@ -2052,12 +2071,16 @@ body.billing-detail-open {
transform: translateX(0);
}
.admin-template-body.admin-sidebar-no-transition .app-sidebar-menu {
transition: none !important;
}
.admin-template-body.admin-sidebar-open .admin-sidebar-backdrop {
display: block;
position: fixed;
inset: 0;
inset: 0 0 auto;
height: 100vh;
height: 100dvh;
height: var(--admin-viewport-height, 100dvh);
z-index: 1000;
border: 0;
background: rgba(0, 8, 26, 0.48);

@ -26,14 +26,59 @@
var sidebarToggle = document.querySelector('.button-toggle-menu');
var sidebarBackdrop = document.querySelector('.admin-sidebar-backdrop');
var sidebarLinks = document.querySelectorAll('.app-sidebar-menu a');
var viewportFrame = 0;
function measureViewportHeight() {
var viewport = window.visualViewport;
if (viewport && viewport.height) {
return Math.ceil(viewport.height + Math.max(0, viewport.offsetTop || 0));
}
return Math.ceil(Math.max(
window.innerHeight || 0,
document.documentElement.clientHeight || 0
));
}
function applyViewportHeight() {
viewportFrame = 0;
var height = measureViewportHeight();
if (height > 0) {
document.body.style.setProperty('--admin-viewport-height', height + 'px');
}
}
function scheduleViewportHeight() {
if (viewportFrame) return;
viewportFrame = window.requestAnimationFrame(applyViewportHeight);
}
function closeSidebar() {
document.body.classList.remove('admin-sidebar-open');
}
function closeSidebarImmediately() {
document.body.classList.add('admin-sidebar-no-transition');
closeSidebar();
window.requestAnimationFrame(function () {
window.requestAnimationFrame(function () {
document.body.classList.remove('admin-sidebar-no-transition');
});
});
}
applyViewportHeight();
window.addEventListener('resize', scheduleViewportHeight, { passive: true });
window.addEventListener('orientationchange', scheduleViewportHeight, { passive: true });
if (window.visualViewport) {
window.visualViewport.addEventListener('resize', scheduleViewportHeight, { passive: true });
window.visualViewport.addEventListener('scroll', scheduleViewportHeight, { passive: true });
}
if (sidebarToggle) {
sidebarToggle.addEventListener('click', function () {
document.body.classList.toggle('admin-sidebar-open');
scheduleViewportHeight();
});
}
@ -68,10 +113,10 @@
});
});
window.addEventListener('pagehide', closeSidebar);
window.addEventListener('pageshow', function (event) {
applyViewportHeight();
if (event.persisted) {
closeSidebar();
closeSidebarImmediately();
}
});
})();

@ -1 +1,2 @@
{assign var=venix_asset_version value='2026092903' scope='global'}
{* Shared Venix CSS/JS cache key. Increment whenever a shared browser asset changes. *}
{assign var=venix_asset_version value='2026092904' scope='global'}

@ -6,6 +6,7 @@ $controllerPath = $root . '/app/Controllers/AdminController.php';
$templatePath = $root . '/resources/views/venix/admin/index.tpl';
$headerPath = $root . '/resources/views/venix/admin/static_header.tpl';
$footerPath = $root . '/resources/views/venix/admin/static_footer.tpl';
$assetsPath = $root . '/resources/views/venix/layout_assets.tpl';
$sharedStylePath = $root . '/public/theme/venix/css/admin-home.css';
$removedStylePath = $root . '/public/cloud/admin-overview.css';
$schemaPath = $root . '/sql/cloud.sql';
@ -25,6 +26,7 @@ $controller = file_get_contents($controllerPath);
$template = file_get_contents($templatePath);
$header = file_get_contents($headerPath);
$footer = file_get_contents($footerPath);
$assets = file_get_contents($assetsPath);
$styles = file_get_contents($sharedStylePath);
$schema = file_get_contents($schemaPath);
$baseSchema = file_get_contents($baseSchemaPath);
@ -103,16 +105,36 @@ $assert(str_contains($header, '/theme/venix/css/admin-home.css')
&& str_contains($styles, '@media (max-width: 575.98px)'),
'Overview must inherit the existing administrator component and responsive rules.');
$assert(preg_match('/\.admin-template \.app-sidebar-menu\s*\{(?=[^}]*height:\s*100vh)(?=[^}]*height:\s*100dvh)[^}]*\}/s', $styles)
&& preg_match('/\.admin-template-body\.admin-sidebar-open \.admin-sidebar-backdrop\s*\{(?=[^}]*height:\s*100vh)(?=[^}]*height:\s*100dvh)[^}]*\}/s', $styles)
&& str_contains($footer, "window.addEventListener('pagehide', closeSidebar)")
$assert(preg_match('/\.admin-template-body\s*\{(?=[^}]*--admin-viewport-height:\s*100vh)(?=[^}]*padding-bottom:\s*0\s*!important)[^}]*\}/s', $styles)
&& preg_match('/@supports\s*\(height:\s*100dvh\)\s*\{\s*\.admin-template-body\s*\{[^}]*--admin-viewport-height:\s*100dvh/s', $styles)
&& preg_match('/\.admin-template#app-layout\s*\{(?=[^}]*height:\s*auto\s*!important)(?=[^}]*overflow:\s*visible\s*!important)[^}]*\}/s', $styles)
&& preg_match('/\.admin-template \.content-page\s*\{(?=[^}]*display:\s*flex)(?=[^}]*flex-direction:\s*column)[^}]*\}/s', $styles)
&& preg_match('/\.admin-template \.content\s*\{(?=[^}]*flex:\s*1 0 auto)[^}]*\}/s', $styles)
&& preg_match('/\.admin-template \.footer\s*\{(?=[^}]*position:\s*static)[^}]*\}/s', $styles)
&& preg_match('/\.admin-template \.app-sidebar-menu\s*\{(?=[^}]*inset:\s*0 auto auto 0)(?=[^}]*height:\s*var\(--admin-viewport-height,\s*100dvh\))[^}]*\}/s', $styles)
&& preg_match('/\.admin-template-body\.admin-sidebar-open \.admin-sidebar-backdrop\s*\{(?=[^}]*inset:\s*0 0 auto)(?=[^}]*height:\s*var\(--admin-viewport-height,\s*100dvh\))[^}]*\}/s', $styles)
&& str_contains($styles, '.admin-template-body.admin-sidebar-no-transition .app-sidebar-menu')
&& str_contains($footer, 'function measureViewportHeight()')
&& str_contains($footer, 'window.visualViewport')
&& str_contains($footer, "window.visualViewport.addEventListener('resize', scheduleViewportHeight")
&& str_contains($footer, "window.visualViewport.addEventListener('scroll', scheduleViewportHeight")
&& !str_contains($footer, "window.addEventListener('pagehide', closeSidebar)")
&& str_contains($footer, "window.addEventListener('pageshow'")
&& str_contains($footer, 'event.persisted')
&& str_contains($footer, 'closeSidebarImmediately();')
&& substr_count($footer, 'window.requestAnimationFrame(function ()') >= 2
&& str_contains($footer, "document.body.classList.toggle('admin-sidebar-open');\n scheduleViewportHeight();")
&& str_contains($footer, 'target.pathname === current.pathname')
&& str_contains($footer, 'target.search === current.search')
&& str_contains($footer, 'target.hash === current.hash')
&& str_contains($footer, 'event.preventDefault();')
&& !preg_match('/link\.addEventListener\(\'click\'.*?window\.innerWidth <= 991.*?closeSidebar\(\);/s', $footer),
'Mobile administrator navigation must cover the dynamic viewport and keep its overlay during cross-page navigation.');
'Mobile administrator navigation must cover the measured viewport and keep its overlay during cross-page navigation.');
$assetVersion = [];
$assert(preg_match("/venix_asset_version value='([0-9]+)'/", $assets, $assetVersion) === 1
&& (int) $assetVersion[1] >= 2026092904
&& str_contains($assets, 'cache key'),
'This administrator asset release must use cache key 2026092904 or newer.');
echo 'Administrator operational overview contracts passed.' . PHP_EOL;

Loading…
Cancel
Save