fix: prevent mobile admin navigation flash

dev
admin 2 months ago
parent 73afe9db50
commit 3aeeff22a7

@ -1,5 +1,6 @@
.admin-template-body {
min-height: 100vh;
min-height: 100dvh;
background: #f3f5f9;
}
@ -22,6 +23,7 @@
inset: 0 auto 0 0;
width: 260px;
height: 100vh;
height: 100dvh;
padding-top: 0 !important;
z-index: 1001 !important;
background: #061836;
@ -44,6 +46,7 @@
.admin-template .content-page {
min-height: 100vh;
min-height: 100dvh;
margin-left: 260px;
margin-top: 0;
padding-top: 72px;
@ -2053,6 +2056,8 @@ body.billing-detail-open {
display: block;
position: fixed;
inset: 0;
height: 100vh;
height: 100dvh;
z-index: 1000;
border: 0;
background: rgba(0, 8, 26, 0.48);

@ -42,12 +42,38 @@
}
sidebarLinks.forEach(function (link) {
link.addEventListener('click', function () {
if (window.innerWidth <= 991) {
link.addEventListener('click', function (event) {
if (window.innerWidth > 991
|| event.defaultPrevented
|| event.button !== 0
|| event.metaKey
|| event.ctrlKey
|| event.shiftKey
|| event.altKey
|| link.target === '_blank'
|| link.hasAttribute('download')) {
return;
}
var target = new URL(link.href, window.location.href);
var current = new URL(window.location.href);
if (target.origin === current.origin
&& target.pathname === current.pathname
&& target.search === current.search) {
if (target.hash === current.hash) {
event.preventDefault();
}
closeSidebar();
}
});
});
window.addEventListener('pagehide', closeSidebar);
window.addEventListener('pageshow', function (event) {
if (event.persisted) {
closeSidebar();
}
});
})();
</script>
{/literal}

@ -5,6 +5,7 @@ $servicePath = $root . '/app/Services/Cloud/CloudAdminOverviewService.php';
$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';
$sharedStylePath = $root . '/public/theme/venix/css/admin-home.css';
$removedStylePath = $root . '/public/cloud/admin-overview.css';
$schemaPath = $root . '/sql/cloud.sql';
@ -23,6 +24,7 @@ $service = file_get_contents($servicePath);
$controller = file_get_contents($controllerPath);
$template = file_get_contents($templatePath);
$header = file_get_contents($headerPath);
$footer = file_get_contents($footerPath);
$styles = file_get_contents($sharedStylePath);
$schema = file_get_contents($schemaPath);
$baseSchema = file_get_contents($baseSchemaPath);
@ -101,4 +103,16 @@ $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)")
&& str_contains($footer, "window.addEventListener('pageshow'")
&& str_contains($footer, 'event.persisted')
&& 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.');
echo 'Administrator operational overview contracts passed.' . PHP_EOL;

@ -754,6 +754,7 @@ foreach (['hosts/index.tpl', 'cloud/instances.tpl', 'cloud/rescue.tpl', 'cloud/t
$adminBillingSource = file_get_contents($adminBillingTemplate);
$assert(str_contains($adminBillingSource,
'/cloud/admin-billing.js?v={$venix_asset_version}')
&& str_contains($adminBillingSource, "{include file='admin/static_footer.tpl'}")
&& !str_contains($adminBillingSource, '/cloud/admin-billing.css')
&& !is_file($adminBillingStyles)
&& str_contains($adminBillingSource, 'admin-ticket-stat')

Loading…
Cancel
Save