MCPcopy Create free account
hub / github.com/formkit/formkit / setActiveStep

Function setActiveStep

packages/addons/src/plugins/multiStep/multiStepPlugin.ts:362–382  ·  view source on GitHub ↗

* Changes the active step to the target step if the target step is allowed. * * @param targetStep - The target step

(targetStep: FormKitFrameworkContext, e?: Event)

Source from the content-addressed store, hash-verified

360 * @param targetStep - The target step
361 */
362async function setActiveStep(targetStep: FormKitFrameworkContext, e?: Event) {
363 if (e) {
364 e.preventDefault()
365 }
366 const parentNode = targetStep?.node.parent
367 if (targetStep && targetStep.node.name && parentNode) {
368 const currentStep = parentNode.props.steps.find(
369 (step: FormKitFrameworkContext) =>
370 step.node.name === parentNode.props.activeStep
371 )
372 if (!currentStep) return
373 const stepIsAllowed = await isTargetStepAllowed(currentStep, targetStep)
374 if (
375 stepIsAllowed &&
376 targetStep.node.parent === parentNode &&
377 parentNode.context
378 ) {
379 parentNode.props.activeStep = targetStep.node.name
380 }
381 }
382}
383
384async function goToStep(node: FormKitNode, target: number | string) {
385 await node.settled

Callers 2

goToStepFunction · 0.85
multiStepPluginFunction · 0.85

Calls 1

isTargetStepAllowedFunction · 0.85

Tested by

no test coverage detected