Guide on navigating to a specific step within a wizard using Vue and TypeScript

In this wizard, there are 6 steps. The last step includes a button that redirects the user back to step 4 when clicked. The user must then complete steps 5 and 6 in order to finish the wizard.

step6.ts

<router-link
        to="/stepFour"
        custom
        v-slot="{ navigate }"
>
        <q-btn
          :ripple="false"
          flat
          :label="$t('pages.projects.project.deviceConnection.validation.symbolDidntBlink')"
          @click="navigate"
          role="link"
        />
</router-link>

router.ts

  const routes = [
  //connect: redirect
  {
    path: 'stepFour',
    name: 'step4',
    component: () => import('components/connection/4_stepFour/stepFour.vue'),
    props: {
      slaveLevel: 1,
    },
  },
];

wizard.vue

<template>
  <q-stepper
    v-bind:value="value"
    v-on:input="handleInput"
    ref="stepper"
    color="primary"
    flat
    class="c-stepper"
    @transition="transitionPanel"
  >
    <slot />

    <template v-slot:navigation>
      <q-card-actions class="c-wizarDialog__footer c-btn__action" align="center">
        <q-btn
          v-if="value > 1 && !disablePreviousButton"
          :ripple="false"
          :disable="disablePreviousButton"
          icon="chevron_left"
          flat
          dense
          size="lg"
          text-color="primary"
          @click="goPrevious($refs)"
          data-cy="wizard-back"
          class="c-btn--previous"
        />

        <q-btn
          :ripple="false"
          v-if="value === numberOfSteps"
          :disable="disableFinishButtonState"
          @click="finish(actionButtonFunction)"
          color="primary"
          :label="$t('general.finish')"
          class="c-btn--finish full-width"
          data-cy="wizard-finish"
        />

        <q-btn
          v-else-if="pShowNextButton"
          :ripple="false"
          :disabled="disableNextButton"
          @click="goToNextStep($refs)"
          color="primary"
          class="c-btn--continue full-width"
          data-cy="wizard-continue"
        >
          {{ $t('general.continue') }}
        </q-btn>
      </q-card-actions>
    </template>
  </q-stepper>
</template>

connection.ts

<template>
  <WizardDialog
    :title="$t('components.appBar.connection')"
    :actionButtonTitle="$t('general.createButtonText')"
    v-on:dialogVisibility="handleDialogVisibility"
    :cancelButtonLabel="''"
  >
    <Wizard
      :number-of-steps="numberOfSteps"
      v-model="step"
      :action-button-function="finishFunction"
      :disable-next-button="disableNextButton"
      :has-step-errors="hasStepErrors"
    >
      <WizardStep
        class="c-identifyDialog"
        :number-of-steps="numberOfSteps"
        :name="0"
        :done="step > 0"
      >
//wizard steps from 1 to 5

      <WizardStep :number-of-steps="numberOfSteps" :name="6" :done="step > 6" v-if="!isHelp">
        <StepSix />
      </WizardStep>
    </Wizard>
  </WizardDialog>
</template>

This section of code implements a redirection to step 4 outside of the wizard interface. Assistance is needed to correct this behavior.

Answer №1

Router-links are designed to update the current page of your app, leading to the stepFour component completely replacing everything. Take a look at Quasar's QStepper API documentation. Utilizing router-links for controlling component navigation is unnecessary as the functionality is built into the component using v-model. Simply changing the v-model value will dictate which step the component displays. Here's a basic example:

<q-stepper
  v-model="step"
>
  <q-step :name="1" />
  <q-step :name="2" />
  <q-step :name="3" />
</q-stepper>

By setting step to a value of 1, 2, or 3 in a function, q-stepper will automatically switch to the corresponding named q-step child component.

Answer №2

Instead of including the code snippet in step6.ts, make changes to the wizard.ts file in the following way.

  <WizardStep :number-of-steps="numberOfSteps" :name="6" :done="step > 6" v-if="!isHelp">
    <StepSix ref="step6" />
    <div >
    <q-btn
        :ripple="false"
        flat
        color="primary"
        class="q-mb-sm full-width"
        @click="redirect()"
      >
        {{ $t('pages.projects.project.deviceConnection.validation.symbolDidntBlink') }}
      </q-btn>
    </div>
  </WizardStep>

This action will direct the user to step4 within the wizard.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The best way to avoid routing before certain async data in the Vuex store has finished loading

I am facing a challenge in my application where I require certain data to be loaded into the VueX store before routing can commence, such as user sessions. An example scenario that showcases a race condition is as follows: // Defined routes { name: &ap ...

Tips for Logging HTTP Communication Errors in Angular

When making an HTTP put call to update a record in my .Net MVC application, I have noticed that the controller's put logic is not being triggered as expected compared to other types of HTTP requests. I want to implement error handling by using the Ha ...

Is there a source where I can locate type definitions for Promise objects?

In the process of creating a straightforward class called Primrose, I am extending the global Promise object in order to include additional methods like resolve and reject. export class Primrose<Resolution> extends Promise<Resolution>{ priv ...

I've encountered an error and am unsure of how to fix it

index.ts:5:8 - error TS1192: Module '"D:/Calculator/node_modules/@types/chalk-animation/index"' does not have a default export. 5 import chalkAnimation from "chalk-animation"; ~~~~~~ index.ts:22:1 - error TS1378: To ...

Tips on preventing Realtime database onWrite trigger function callback from iterating through data that has been altered

I am currently developing a 1 vs 1 game matching system using a real-time database. The system works by creating a record in the users table when a user signs in. Once there are two players with a status of placeholder, a cloud function generates a gameInf ...

Unable to construct a node typescript project using solely production dependencies

I am currently working on a Node TypeScript project that utilizes various third-party libraries such as express. To ensure type safety, I typically install the @types/express module as a dev dependency following common instructions. The installation works ...

Differences between Typescript static methods and functions defined outside of classesWhen comparing Types

What distinguishes a static class method from a function defined outside a class in TypeScript, especially when visibility is not a concern? While there are differences in visibility from other classes and files, what factors should be considered when dec ...

What is preventing absolute paths from functioning properly in TurboRepo?

After setting up a fresh project on the most recent version of TurboRepo, I ventured into the 'apps' directory and established a new Vite project using the 'react-swc-ts' template. Making tweaks to the 'tsconfig.json' file wit ...

The dom does not automatically update when data is modified inside the watch function

Here is the data within a component: data: function () { return { sltAreaStyle: { paddingTop: "3%", }, checkedTypes: ["krw", "btc", "usdt"], }; }, Next, we have the watch function for the checkedTypes d ...

A step-by-step guide on upgrading or transferring from Vite 2 to Vite 3 using NPM while harnessing the power of Vue

While it may seem like a straightforward question, I found myself unable to locate the specific process or commands for upgrading from Vite 2 to Vite 3 using npm. Despite reading the announcement and the migration guide (along with other resources), I ha ...

What is the best way to conceal a global component like a navbar on specific routes?

Most of the pages on my vuejs SPA feature a top navbar component, but there are certain views like the login page where I do not want it to be displayed. My current solution involves importing the navbar and adding it to each view separately when needed. ...

Tips for achieving a seamless user experience with Vue-bootstrap popovers

My Vue application consists of multiple cards, each displaying a button when hovered over. Additionally, hovering over the button triggers a popover to appear. However, I am experiencing issues with the popover behavior - it blinks when attempting to acces ...

React Traffic Light Component: Colors Stuck After Timeout

I've been working on solving a React issue and followed a tutorial on YouTube. I'm using CodeSandbox for my project, but I'm facing a problem where the colors of the signal are not showing up and do not change after some time. I even tried u ...

Integrating fresh components into a JSON structure

I've been attempting to insert a new element into my JSON, but I'm struggling to do it correctly. I've tried numerous approaches and am unsure of what might be causing the issue. INITIAL JSON INPUT { "UnitID":"1148", "UNIT":"202B", "Sp ...

Is there a way to ensure that the div of my template spans 100% in width and height?

I'm attempting to make my div 100% in size but I am having trouble achieving it. Here is my code: <template> <div> <Navbar/> <Calendar/> </div> </template> <script setup> import Calendar from &apos ...

The button's status changes to disabled until I click outside the input field in Angular

I am currently facing an issue with a form (heat index calculator) that requires 2 inputs - a dropdown and a button. The button is disabled when there are no inputs or if the inputs are invalid. Everything works correctly, except for the fact that even whe ...

Is there a way to verify a user's login status?

Currently, I am working on an angular 13 project and incorporating @angular/fire 7 into my development process. I have developed a service with various functions for injection. Below is the code snippet: import { Injectable } from '@angular/core&apos ...

Unlocking the secrets of accessing elements within a Vue.js template using $refs

I am facing an issue with an h1 element that is truncating text if it is too long to fit on the screen, displaying an ellipsis when this occurs. In order to determine whether the ellipsis is active or not, I attempted to use a ref on the h1 element and th ...

A guide on integrating a stacked bar chart from ApexCharts into a modal or v-dialog component

I'm facing a minor issue with vue-apexcharts while attempting to showcase some data in a stacked bar chart. Here is the simple component I have created: <template> <div v-if="this.loaded"> <apexchart w ...

Receiving the latest state from Vuex in a Vue3 component

Is there a way to update the user state in Vuex and have it reflect instantly on the frontend without requiring a page reload? I've searched for solutions but haven't found any that work for me. I'm currently exporting the store as a functi ...