From 1a3031593ea3fb6fb0d3b32ecc1b1c79a2bf0c45 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Fri, 9 Feb 2024 18:20:54 +0800 Subject: [PATCH] Fix interactive tutorials issues --- @theme/markdoc/components.tsx | 6 ++++-- static/js/interactive-tutorial.js | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) 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(() => {