fix(app-config): restore config sub-tab on cold-load deep-link/refresh

/app/<name>/config/<sub> URLs (e.g. .../config/ports) are generated by the app
itself and shown in the address bar, but a refresh or deep-link always reset to
the first config category. Cause: showAppDetail() rebuilt the URL via
appPath(appName, targetTab) with NO sub argument and pushState'd it BEFORE
renderAppDetail() read the sub back off the path — so the /<sub> segment was
already gone and preferredCategory stayed null.

Preserve the sub when the URL already points at this app's config (matched by
appPartsFromPath().app === appName), so cold-load/refresh lands on the encoded
sub-tab. Cross-app switches still start at the first category. The sibling
showAppDetailWithConfig() (the grid 'manage' button) is intentionally left to
land on the first category.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: librelad <librelad@digitalangels.vip>
This commit is contained in:
librelad 2026-06-18 16:42:46 +01:00
parent f4784b5fc1
commit 0d5ae61e32

View File

@ -374,7 +374,19 @@ class AppsManager {
targetTab = currentUrl.searchParams.get('tab') || 'config'; targetTab = currentUrl.searchParams.get('tab') || 'config';
} }
const newUrl = window.appPath(appName, targetTab); // Preserve the config sub-category (/app/<name>/config/<sub>) when the URL
// already points at THIS app's config. Without this, rebuilding the URL
// here strips the sub before renderAppDetail reads it back off the path, so
// a cold-load deep-link / refresh of e.g. /app/bookstack/config/ports always
// reset to the first category. Only kept for the same app — a cross-app
// switch intentionally starts at the first category.
let targetSub = null;
if (targetTab === 'config' && window.appPartsFromPath) {
const parts = window.appPartsFromPath(window.location.pathname);
if (parts.tab === 'config' && parts.app === appName) targetSub = parts.sub;
}
const newUrl = window.appPath(appName, targetTab, targetSub);
history.pushState({}, '', newUrl); history.pushState({}, '', newUrl);
// Update app-tabbed-manager BEFORE rendering the DOM. If renderAppDetail or // Update app-tabbed-manager BEFORE rendering the DOM. If renderAppDetail or