Add Skip Tour button to Shepherd.js tour and fix event listener clean…#267
Add Skip Tour button to Shepherd.js tour and fix event listener clean…#267aadityabinodyadav wants to merge 2 commits intoaccordproject:mainfrom
Conversation
✅ Deploy Preview for ap-template-playground ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
…up (accordproject#260) Signed-off-by: Aaditya Binod Yadav <aadityarayyadav@gmail.com>
Signed-off-by: Aaditya Binod Yadav <aadityarayyadav@gmail.com>
51530e5 to
d93476d
Compare
|
#261 already solved this |
|
@DianaLease let me know if there is something I can improve! |
Thanks for the update! |
|
Can you please rebase your branch and remove conflicts? |
|
I don't see any discussion on the issue. Also I see two similar PRs? I'm a bit confused here. Was this resolution discussed with the issue reporter and the maintainers? Also I see a PR already raised by the issue reporter and I don't see any discussion about a similar being PR being raised. @aadityabinod |
|
Hey everyone! I misunderstood issue #260 as a problem to solve, but it was a feature request with an existing PR. I’ve replied on my PR #267 , offering to collaborate or close if needed. Waiting for guidance—sorry for the mix-up 😅 |
No worries, closing this one as a duplicate of #261 |
Pull Request: Add a Skip Button to the Tour
Issue
CLOSES #260
Description
This pull request adds a "Skip Tour" button to the Shepherd.js tour in the
template-playgroundapplication. The goal is to allow users to exit the onboarding tour at any step, improving user experience. Additionally, this PR fixes TypeScript errors that caused the initial deploy preview to fail.Changes Made
1. Added "Skip Tour" Button to
tour.tssrc/components/Tour.tsdefaultStepOptions.buttonsfor all steps unless overridden.buttonsarray.#ff4d4f) using the.skip-tourclass.tour.cancel()to end the tour.: Tour) to fixTS7022: 'tour' implicitly has type 'any'.2. Updated
App.tsxsrc/App.tsxisTourRunningstate and used it in JSX to display a "Tour is running..." message, fixingTS6133: 'isTourRunning' is declared but its value is never read.completeandcancelto manage the state.isTourRunningstate and replaced it with a used version.3. Code Snippets
tour.ts(partial):jsx
Collapse
Wrap
Copy
const [isTourRunning, setIsTourRunning] = useState(false);
useEffect(() => {
const showTour = searchParams.get("showTour") === "true";
if (showTour || !localStorage.getItem("hasVisited")) {
setIsTourRunning(true);
tour.start();
localStorage.setItem("hasVisited", "true");
tour.on("complete", () => setIsTourRunning(false));
tour.on("cancel", () => setIsTourRunning(false));
}
return () => {
tour.off("complete", () => setIsTourRunning(false));
tour.off("cancel", () => setIsTourRunning(false));
};
}, [searchParams]);
-Why These Changes?
1.User Experience: Adds a "Skip Tour" button for flexibility.
2.Consistency: Integrates the button within the tour UI.
3.Bug Fix: Resolves TypeScript errors that caused the deploy preview failure.
//Testing Instructions
1.Start the Tour:
Clear localStorage.hasVisited or use ?showTour=true.
2.Confirm the tour starts.
Verify the "Skip Tour" Button:
Check that the button appears in each step (red background).
Click it to ensure the tour ends.
3.Verify Tour State:
The "Tour is running..." message should appear during the tour and disappear when skipped or finished.
Check for Errors:
4.Ensure no console errors and the deploy preview passes (✅).
//Additional Notes
//Checklist
-Added "Skip Tour" button to all tour steps in tour.ts.
-Fixed TS6133 and TS7022 errors.
-Tested locally (start, skip, complete).
-Ensured no runtime errors.