From e3f46083afc967c6e654d074f25ab943995ae546 Mon Sep 17 00:00:00 2001 From: Bassel Ashi Date: Wed, 17 Jan 2024 23:56:31 -0500 Subject: [PATCH 1/2] Delay retrieving tip until action --- src/TipManager.js | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/TipManager.js b/src/TipManager.js index 651070f..b645c41 100644 --- a/src/TipManager.js +++ b/src/TipManager.js @@ -93,31 +93,28 @@ class TipManager { ? stepTourProps.prevId : stepTourProps.nextId - let tip = this.tips.find(i => i.id === id) - - if (!tip) { - if (tries > 10) { - return alert('Timeout! Tip id not found after 10 tries (2500ms)! Verify if the item is registered by the time you are calling it.') - } - - tries++ - return setTimeout(showItem, 250) - } - - tip.tourProps = this.steps.find(i => i.id === id) - tip = { ...tip, ...tip.tourProps.tipProps } - if (direction === 'prev' && stepTourProps.prevAction) { stepTourProps.prevAction() - setTimeout(() => this.tipProvider.showTip(tip), stepTourProps.delay || 10) - return + setTimeout(() => { + const tip = getTip(id) + this.tipProvider.showTip(tip) + }, stepTourProps.delay || 10) } else if (direction === 'next' && stepTourProps.nextAction) { stepTourProps.nextAction() - setTimeout(() => this.tipProvider.showTip(tip), stepTourProps.delay || 10) - return + setTimeout(() => { + const tip = getTip(id) + this.tipProvider.showTip(tip) + }, stepTourProps.delay || 10) + } else { + this.tipProvider.showTip(tip) } + } - this.tipProvider.showTip(tip) + const getTip = (id) => { + let tip = this.tips.find(i => i.id === id) + tip.tourProps = this.steps.find(i => i.id === id) + tip = { ...tip, ...tip.tourProps.tipProps } + return tip } setTimeout(showItem, 0) From 536400a92e239af7588a13684199d5da4966c241 Mon Sep 17 00:00:00 2001 From: Bassel Ashi Date: Thu, 18 Jan 2024 00:03:25 -0500 Subject: [PATCH 2/2] Add tip retrieval in last case --- src/TipManager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/TipManager.js b/src/TipManager.js index b645c41..b29d979 100644 --- a/src/TipManager.js +++ b/src/TipManager.js @@ -106,6 +106,7 @@ class TipManager { this.tipProvider.showTip(tip) }, stepTourProps.delay || 10) } else { + const tip = getTip(id) this.tipProvider.showTip(tip) } }