Skip to content
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

onPreventChange() callback not firing #115

Open
jaimefps opened this issue Aug 11, 2024 · 1 comment
Open

onPreventChange() callback not firing #115

jaimefps opened this issue Aug 11, 2024 · 1 comment

Comments

@jaimefps
Copy link

jaimefps commented Aug 11, 2024

Describe the bug

onPreventChange() callback not firing when onBeforeChange() returns a Promise that outputs false.
Also seeing what I suspect is the incorrect value passed to onPreventChange()

To Reproduce

// first issue example

  <Steps
      // some large amount of steps:
      steps={[{..}, {..}, {..}]}
      
      // async attempt to skip step 1
      onBeforeChange={async (step) => {
            if (step == 1) return 2
      })
      
      // try to detect the skip:
      onPreventChange={(step) => {
        // this never logs
        console.log({ skipped: step })
      }}
    />

// second issue example

  <Steps
      // some large amount of steps:
      steps={[{..}, {..}, {..}]}
      
      // attempt to skip step 1
      onBeforeChange={(step) => {
            if (step == 1) return 2
      })
      
      // try to detect the skip:
      onPreventChange={(step) => {
        // logs 0, instead of 1
        console.log({ skipped: step }) 
      }}
    />

Expected behavior

I'd expect that if the returned Promise from onBeforeChange() itself outputs a false, then we still get to fire onPreventChange()

How often does this bug happen?

Every time

System Info

macOS 14.5 (23F79)
Chromium browsers

Additional Context

No response

@HiDeoo
Copy link
Owner

HiDeoo commented Aug 12, 2024

Thanks for the feedback.

Indeed, the intro.js-react props onBeforeChange is not a 1:1 match with the intro.js onbeforechange callback function. The current implementation does not seem to support a promise-based approach.

I would be open to reviewing a PR that adds support for a promise-based approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants