Menu
FeaturesPricingAboutFAQGuidesNPS calculatorTemplatesSign inView 7-day trial

Testing a guide inside a collapsed sidebar

Expand the sidebar before anchoring

A step that points inside a collapsed sidebar may not find its element because the panel is hidden in the DOM or has zero dimensions. Before the step activates, trigger the sidebar’s open action programmatically. If the sidebar toggles via a button with aria-controls="nav-panel", call document.querySelector('[aria-controls="nav-panel"]').click() and wait for the panel’s aria-expanded="true" state.

Guard against race conditions

The sidebar animation may take 200–300 ms. After triggering the open action, poll for the target element’s offsetParent !== null or a CSS visibility: visible check. Only then attach the tour tooltip. If the element does not appear within a generous timeout (e.g., 1.5 s), log a warning and skip the step rather than hanging the tour.

Worked example: "Invite Team" step in collapsed nav

Sidebar markup: <button id="nav-toggle" aria-controls="main-nav" aria-expanded="false">Menu</button> and <nav id="main-nav" hidden>…<a data-tour-step="invite-team" href="/invite">Invite Team</a></nav>. Tour step config includes a preStep function:

async function openSidebar() {
  const btn = document.querySelector('#nav-toggle');
  if (btn.getAttribute('aria-expanded') === 'false') btn.click();
  await waitFor(() => document.querySelector('[data-tour-step="invite-team"]').offsetParent !== null, 1500);
}

The step now appears reliably whether the sidebar starts open or closed.

Exception: sidebar rendered lazily

Some frameworks only inject the sidebar markup after the first open. In that case the target element does not exist until after the toggle. The same preStep can work because waitFor polls the DOM after the click; just ensure the selector matches the eventual markup, not a placeholder.

Result: the "Invite Team” tooltip can appear centered on the link regardless of the sidebar’s initial state.

Related: Onboarding Tours features.