Giter Site home page Giter Site logo

Comments (8)

hakimio avatar hakimio commented on May 17, 2024 1

Ok, I think I understand what's the problem. It shouldn't even start listening to NavigationStart event if it didn't navigate anywhere (isRouteActive == true).

from ngx-ui-tour.

hakimio avatar hakimio commented on May 17, 2024

Not sure if it's more sensible to try to guess which step should be selected or to just end the tour. I am leaning towards just ending the tour since there might no longer be an anchor element or the step might require pressing UI element which might cause issues when pressed multiple times.

from ngx-ui-tour.

mivanyna avatar mivanyna commented on May 17, 2024

Maybe some kind of confirmation modal in this case?
Or an option for what to do in such cases?

Btw, a similar issue is when no backdrop is shown and fragment is changed - tooltip disappears, but tourService status - on

from ngx-ui-tour.

mivanyna avatar mivanyna commented on May 17, 2024

Btw, a similar issue is when no backdrop is shown and fragment is changed - tooltip disappears, but tourService status - on

@hakimio, What do you think if adding a check into setCurrentStep function to only hide the step if url is not active or anchor isn't available:

private setCurrentStep(step: T): void {
        this.currentStep = step;
        this.showStep(this.currentStep);
        this.router.events
            .pipe(filter(event => event instanceof NavigationStart), first())
            .subscribe(() => {
                if (this.currentStep && this.currentStep.hasOwnProperty('route') && (!this.isActiveRoute(step) || !this.anchors[step.anchorId])) {
                    this.hideStep(this.currentStep);
                }
            });
    }

private isActiveRoute(step: T) {
        if (!step.route) {
            return true
        }

        const url = typeof step.route === 'string' ? step.route : this.router.createUrlTree(step.route),
          matchOptions: IsActiveMatchOptions = {
              paths: 'exact',
              matrixParams: 'exact',
              queryParams: 'subset',
              fragment: 'ignored'
          };

        return this.router.isActive(url, matchOptions);
    }

from ngx-ui-tour.

hakimio avatar hakimio commented on May 17, 2024

Not sure what you are trying to achieve here.
Anyway, I have decided to just end the tour if user navigates to a different page.
You can use route guard to prevent user from being able to navigate to a different page when tour is active.

from ngx-ui-tour.

mivanyna avatar mivanyna commented on May 17, 2024

Example: Tooltip is shown on the left menu and the user switches tabs on the right side (fragment only changes in url - someUrl#tab1 => someUrl#tab2)

from ngx-ui-tour.

mivanyna avatar mivanyna commented on May 17, 2024

One more thing I noticed is that there are subscriptions to this.router.events in setCurrentStep and no unsubscribe.
It seems that with time and going back and forward between steps may cause lots of subscriptions that would be attached and stay there forever. Even when the tour is finished.

from ngx-ui-tour.

hakimio avatar hakimio commented on May 17, 2024

It's using first() operator to unsubscribe after the first emition.

from ngx-ui-tour.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.