Compare commits

...

3 Commits

Author SHA1 Message Date
Bentlybro
9b71c03d96 Add 'Back' button to tutorial popover
Introduces a 'Back' button to the blocks control popover in the tutorial, allowing users to navigate to the previous step.
2025-08-20 11:57:39 +01:00
Bentlybro
b20b00a441 prettier 2025-08-20 11:13:08 +01:00
Bentlybro
84810ce0af Add delay and safeguard for tutorial popover initialization
Introduces a short delay before starting the tutorial in FlowEditor to ensure component state is initialized, especially after redirects. Also adds a safeguard in the tutorial to keep the blocks popover pinned during the relevant step.
2025-08-20 11:05:37 +01:00
2 changed files with 21 additions and 6 deletions

View File

@@ -186,10 +186,16 @@ const FlowEditor: React.FC<{
storage.clean(Key.SHEPHERD_TOUR);
router.push(pathname);
} else if (!storage.get(Key.SHEPHERD_TOUR)) {
const emptyNodes = (forceRemove: boolean = false) =>
forceRemove ? (setNodes([]), setEdges([]), true) : nodes.length === 0;
startTutorial(emptyNodes, setPinBlocksPopover, setPinSavePopover);
storage.set(Key.SHEPHERD_TOUR, "yes");
// Add a small delay to ensure the component state is fully initialized
// This is especially important when resetTutorial=true caused a redirect
const timer = setTimeout(() => {
const emptyNodes = (forceRemove: boolean = false) =>
forceRemove ? (setNodes([]), setEdges([]), true) : nodes.length === 0;
startTutorial(emptyNodes, setPinBlocksPopover, setPinSavePopover);
storage.set(Key.SHEPHERD_TOUR, "yes");
}, 100);
return () => clearTimeout(timer);
}
}, [router, pathname, params, setEdges, setNodes, nodes.length]);

View File

@@ -190,7 +190,12 @@ export const startTutorial = (
element: '[data-id="blocks-control-popover-content"]',
on: "right",
},
buttons: [],
buttons: [
{
text: "Back",
action: tour.back,
},
],
beforeShowPromise: () =>
waitForElement('[data-id="blocks-control-popover-content"]').then(() => {
disableOtherBlocks(
@@ -202,7 +207,11 @@ export const startTutorial = (
event: "click",
},
when: {
show: () => setPinBlocksPopover(true),
show: () => {
setPinBlocksPopover(true);
// Additional safeguard - ensure the popover stays pinned for this step
setTimeout(() => setPinBlocksPopover(true), 50);
},
hide: enableAllBlocks,
},
});