From a521b415f4c92a7c7f6f95d21dd848fd9eda9cf7 Mon Sep 17 00:00:00 2001 From: Siyamak Date: Thu, 6 Aug 2020 02:46:33 +0430 Subject: [PATCH 1/3] Check steps after unregister a step, and stop copilot if there is no more step --- src/hocs/copilot.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/hocs/copilot.js b/src/hocs/copilot.js index 85d09659..04c7dd1d 100644 --- a/src/hocs/copilot.js +++ b/src/hocs/copilot.js @@ -135,7 +135,10 @@ const copilot = ({ steps: Object.entries(steps) .filter(([key]) => key !== stepName) .reduce((obj, [key, val]) => Object.assign(obj, { [key]: val }), {}), - })); + }), () => { + if(Object.values(this.state.steps).length === 0 && this.state.visible) + this.stop(); + }); } next = async (): void => { From b3778cebff06a21155b11051f4ec22101283738c Mon Sep 17 00:00:00 2001 From: Siyamak Date: Thu, 6 Aug 2020 03:41:52 +0430 Subject: [PATCH 2/3] Change linebreak-style to LF --- src/hocs/copilot.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/hocs/copilot.js b/src/hocs/copilot.js index 04c7dd1d..074d8ef7 100644 --- a/src/hocs/copilot.js +++ b/src/hocs/copilot.js @@ -136,6 +136,7 @@ const copilot = ({ .filter(([key]) => key !== stepName) .reduce((obj, [key, val]) => Object.assign(obj, { [key]: val }), {}), }), () => { + // check to stop copilot, if there is no more step remains if(Object.values(this.state.steps).length === 0 && this.state.visible) this.stop(); }); From d34767383a3f0bf95bedc97ef234028060205b26 Mon Sep 17 00:00:00 2001 From: Siyamak Date: Thu, 6 Aug 2020 03:58:52 +0430 Subject: [PATCH 3/3] Fix lint errors --- src/hocs/copilot.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hocs/copilot.js b/src/hocs/copilot.js index 074d8ef7..6cdec423 100644 --- a/src/hocs/copilot.js +++ b/src/hocs/copilot.js @@ -136,9 +136,9 @@ const copilot = ({ .filter(([key]) => key !== stepName) .reduce((obj, [key, val]) => Object.assign(obj, { [key]: val }), {}), }), () => { - // check to stop copilot, if there is no more step remains - if(Object.values(this.state.steps).length === 0 && this.state.visible) + if (Object.values(this.state.steps).length === 0 && this.state.visible) { this.stop(); + } }); }