vue-tour icon indicating copy to clipboard operation
vue-tour copied to clipboard

Support next/prev function with the behavior that step is skipped with TargetNotFound

Open quroom opened this issue 2 years ago • 2 comments

This is not a bug. This function will improve vue-tour behavior when the tag element is not founded.

I use next/prev override function like below. How do you think it supported in vue-tour with selectable option?

    nextStepTour(currentStep) {
      for (var i = currentStep + 1; i < this.steps.length; i++) {
        const target_element = document.querySelector(this.steps[i].target);
        if (target_element) {
          if (i == currentStep + 1) {
            break;
          } else {
            const tour = this.$tours["home"];
            this.$nextTick(() => {
              tour.currentStep = i;
            });
            break;
          }
        }
      }
    },
    previousStepTour(currentStep) {
      for (var i = currentStep - 1; i > -1; i--) {
        const target_element = document.querySelector(this.steps[i].target);
        if (target_element) {
          if (i == currentStep - 1) {
            break;
          } else {
            const tour = this.$tours["home"];
            this.$nextTick(() => {
              tour.currentStep = i;
            });
            break;
          }
        }
      }
    }

quroom avatar Aug 17 '21 03:08 quroom

Maybe we need to add additional codes to check last step to change buttons showing.

quroom avatar Aug 18 '21 00:08 quroom

@quroom how do you account for the events that are meant to be triggered before the step. For example: if I assign a click event to a dropdown before highlighting the dropdown so that i could highlight it's active state but if I use these custom navigation functions then it would fail to find the element in the dom and skips that step. Dom would only see that element when it is clicked.

Jappan07 avatar May 24 '22 06:05 Jappan07