diff --git a/@theme/markdoc/components.tsx b/@theme/markdoc/components.tsx
index 6fb6bdf090..5b98d38e8f 100644
--- a/@theme/markdoc/components.tsx
+++ b/@theme/markdoc/components.tsx
@@ -31,7 +31,8 @@ export function InteractiveBlock(props: { children: React.ReactNode; label: stri
const { pathname } = useLocation();
return (
-
+ // add key={pathname} to ensure old step state gets rerendered on page navigation
+
-
{dynamicReact(props.children, React, {})}
+
+
{dynamicReact(props.children, React, {})}
);
diff --git a/static/js/interactive-tutorial.js b/static/js/interactive-tutorial.js
index 92484e6d54..765b587f52 100644
--- a/static/js/interactive-tutorial.js
+++ b/static/js/interactive-tutorial.js
@@ -629,6 +629,9 @@ async function show_log(block, msg) {
block.find(".output-area").append(msg)
}
+/**
+ * Run callback only when the current route is loaded.
+ */
function onCurrentRouteLoaded(callback) {
const currentPath = window.location.pathname;
window.onRouteChange(() => {