v1.03.78 | 6-27-26
Refactored how navigation flows when a user enters an active lesson block. Previously, I had the topbar fade down to opacity: 0.5 via a body class state, and a separate, clunky #lesson-back-btn floating fixed at the top-left of the viewport. It wasn’t great, and I thought i could do way better.
So instead i cleaned it up, removed the fade, and pretty much “hijacked” the main elements. The standard topbar elements were set to display:none; with the user profile button getting set to half opacity and non-clickable. changed existing #nav-explorer slot by transforming its text to ← Return and changing its weight.
also changed the if (!confirm()) basic alert for my better error alert box. duplicated the old alert box and made another for this one, fit with a cancel button and all.
The main obstacle was handling the application’s default click-routing initialization handlers. Simply changing the .onclick property didn’t work because hidden layout listeners attached via .addEventListener() were catching the event bubbles and dumping the user back to the main curriculum selector immediately anyway. (because remember were hijacking the explore btn)
Fixed it by utilizing Event Capturing:
topNavBtn.addEventListener("click", window.activeTopbarGate, true);
by passing true, the browser catches the user’s click at the absolute top of the DOM tree before the default routers can see it. Inside the wrapper, i ran e.stopPropagation() to stalls the execution chain while the custom gate logic processes.
standard browser alerts freeze javascript synchronously, but custom DOM boxes are asynchronous so a normal return gate wouldn’t cut it. i solved it by wrapping all my navigation cleanup loops inside a functional callback and passing it straight into the dialog box. hit OK, the callback fires and drops you out of the lesson; hit cancel, it just clears the overlay div out of the DOM tree so you can keep working.
its like weaving a thread in a spiderweb (T - T)
also wut u guys feel about the better formatting lemme know, i don’t want it to sound like i just copy pasted chatgpt but i want to explain it better so im a bit conflicted