fix: playground back button goes to previous lesson

The Back button in playground now works the same as Previous button
on other pages - it navigates to the previous lesson.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
This commit is contained in:
2026-01-16 15:00:13 +01:00
parent 33b4b64f13
commit 578be3de2e
2 changed files with 20 additions and 11 deletions

View File

@@ -793,14 +793,6 @@ function nextLesson() {
function prevLesson() {
const engineState = lessonEngine.getCurrentState();
const isPlayground = engineState.lesson?.mode === "playground";
// In playground mode, "Back" navigates to home
if (isPlayground) {
navigateTo("#");
return;
}
const prevModuleId = engineState.module?.id;
const success = lessonEngine.previousLesson();
if (success) {

View File

@@ -52,8 +52,15 @@ export async function handleOAuthCallback() {
}
}
// Clear the hash after processing
window.history.replaceState(null, "", window.location.pathname);
// Restore the original route (saved before OAuth redirect)
const savedRoute = localStorage.getItem("codeCrispies.oauthReturnRoute");
if (savedRoute) {
localStorage.removeItem("codeCrispies.oauthReturnRoute");
window.history.replaceState(null, "", window.location.pathname + savedRoute);
} else {
// No saved route - just clear the hash
window.history.replaceState(null, "", window.location.pathname);
}
return true;
} catch (e) {
@@ -322,8 +329,13 @@ function setupAuthForms() {
}
});
// OAuth buttons
// OAuth buttons - save current route before redirect
document.getElementById("google-login")?.addEventListener("click", async () => {
// Save current route to restore after OAuth
const currentHash = window.location.hash;
if (currentHash && !currentHash.includes("access_token")) {
localStorage.setItem("codeCrispies.oauthReturnRoute", currentHash);
}
const { error } = await authModule?.signInWithGoogle() ?? { error: null };
if (error) {
showOAuthError(error.message);
@@ -331,6 +343,11 @@ function setupAuthForms() {
});
document.getElementById("github-login")?.addEventListener("click", async () => {
// Save current route to restore after OAuth
const currentHash = window.location.hash;
if (currentHash && !currentHash.includes("access_token")) {
localStorage.setItem("codeCrispies.oauthReturnRoute", currentHash);
}
const { error } = await authModule?.signInWithGitHub() ?? { error: null };
if (error) {
showOAuthError(error.message);