-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Fix/step order #2153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fix/step order #2153
Changes from 2 commits
e581159
dbb5d59
301143d
7a898f9
c367888
c7f1541
e049a36
d350ea0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -203,18 +203,32 @@ export class Tour implements Package<TourOptions> { | |
| * Set the current step of the tour and the direction of the tour | ||
| * @param step | ||
| */ | ||
| setCurrentStep(step: number): this { | ||
| async setCurrentStep(step: number): Promise<boolean> { | ||
| const currentStep = this._currentStepSignal.val; | ||
| const targetStep = this.getStep(step); | ||
Parvinmh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (!targetStep) return false; | ||
|
|
||
| const direction = | ||
| currentStep === undefined || step >= currentStep ? "forward" : "backward"; | ||
|
|
||
| const continueStep = await this.callback("beforeChange")?.call( | ||
| this, | ||
| targetStep.element as HTMLElement, | ||
| currentStep, | ||
| direction | ||
| ); | ||
|
|
||
| if ( | ||
| this._currentStepSignal.val === undefined || | ||
| step >= this._currentStepSignal.val | ||
| direction === "forward" && | ||
| continueStep === false && | ||
| currentStep !== undefined | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be Consider this case, what if there is a step (currentStep !== undefined) but
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No — it should remain continueStep === false && currentStep !== undefined because we only want to block the step change when the callback explicitly returns false, and there is an existing step to stay on. |
||
| ) { | ||
| this._direction = "forward"; | ||
| } else { | ||
| this._direction = "backward"; | ||
| return false; | ||
| } | ||
|
|
||
| this._direction = direction; | ||
| this._currentStepSignal.val = step; | ||
| return this; | ||
| return true; | ||
Parvinmh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| /** | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.