fix: Back-Button Fallback auf Dashboard wenn kein History-Eintrag

- router.js: Back-Buttons navigieren zu data-page oder dashboard statt history.back()
- chat-page.js: Chat Back-Button mit gleichem Fallback
- Behebt Problem bei Direktlinks (z.B. #chat/123) ohne vorherigen SPA-Eintrag
This commit is contained in:
Meleki committed 2026-03-12 11:37:48 +01:00
1 parent 982aa60376
commit 1228dc9d58
2 files changed
+14 -2

No files matched your search

+7 -1
View File
@@ -267,7 +267,13 @@ registerPage('chat', {
// Zurück zum Dashboard
const backBtn = document.getElementById('chatBackBtn');
if (backBtn) {
backBtn.addEventListener('click', () => history.back());
backBtn.addEventListener('click', () => {
if (history.state && history.length > 2) {
history.back();
} else {
navigateTo('dashboard');
}
});
}
// Send / Stop
+7 -1
View File
@@ -46,7 +46,13 @@ async function navigateTo(page, params = {}, options = {}) {
// Back-Buttons verdrahten
document.querySelectorAll('.back-btn[data-page]').forEach(btn => {
btn.addEventListener('click', () => history.back());
btn.addEventListener('click', () => {
if (history.state && history.length > 2) {
history.back();
} else {
navigateTo(btn.dataset.page || 'dashboard');
}
});
});
}