Fix interactive tutorials issues

This commit is contained in:
Roman Hotsiy
2024-02-09 18:20:54 +08:00
parent 498bf7007b
commit 1a3031593e
2 changed files with 7 additions and 2 deletions

View File

@@ -31,7 +31,8 @@ export function InteractiveBlock(props: { children: React.ReactNode; label: stri
const { pathname } = useLocation(); const { pathname } = useLocation();
return ( return (
<div className="interactive-block" id={'interactive-' + stepId}> // add key={pathname} to ensure old step state gets rerendered on page navigation
<div className="interactive-block" id={'interactive-' + stepId} key={pathname}>
<div className="interactive-block-inner"> <div className="interactive-block-inner">
<div className="breadcrumbs-wrap"> <div className="breadcrumbs-wrap">
<ul <ul
@@ -53,7 +54,8 @@ export function InteractiveBlock(props: { children: React.ReactNode; label: stri
})} })}
</ul> </ul>
</div> </div>
<div className="interactive-block-ui" key={pathname}>{dynamicReact(props.children, React, {})}</div>
<div className="interactive-block-ui">{dynamicReact(props.children, React, {})}</div>
</div> </div>
</div> </div>
); );

View File

@@ -629,6 +629,9 @@ async function show_log(block, msg) {
block.find(".output-area").append(msg) block.find(".output-area").append(msg)
} }
/**
* Run callback only when the current route is loaded.
*/
function onCurrentRouteLoaded(callback) { function onCurrentRouteLoaded(callback) {
const currentPath = window.location.pathname; const currentPath = window.location.pathname;
window.onRouteChange(() => { window.onRouteChange(() => {