Skip to main content
This document describes how to programmatically navigate to pages and fields within a form using the goto API on Navigator.

Overview

The goto method enables programmatic navigation to specific locations within a form. This is useful for:
  • Guiding users to required fields after validation
  • Implementing custom navigation flows
  • Deep linking to specific form sections
  • Auto-scrolling to specific fields
Instantiate Navigator and pass it to the JoyDoc component via the navigator prop. Then call navigator.goto(path) with a path string whenever you want to navigate.

Path-Based Navigation

Navigate using a slash-separated path string.
Important: Use fieldPositionId from page.fieldPositions[]._id, not fieldId from document.fields[]._id. Using the wrong ID will cause navigation to fail.
The goto method returns an object indicating success or failure.
Failure reasons include:
  • Page does not exist
  • Page is hidden (due to conditional logic)
  • Field position does not exist
  • Field is hidden (due to conditional logic)
  • Field type is unsupported (e.g. file, unknown)
  • Navigating to a hidden field: the page still switches and scrolls to the top of the page, but status is "failure"

Page Change Events

Page changes triggered by goto() or by the user clicking a page in the UI are emitted through the onBlur and onFocus callbacks (the navigation listener). When the active page changes, the SDK fires a page event so you can track which page is focused. Check the type property on the event to distinguish page events from field focus/blur events:
Page event payload: For all event options (including field-level focus/blur), see Event Handling.