Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(onboarding): stepper (#6812)
teof5501173bc66
diff --git a/apps/web/src/components/ui/components/Stepper.test.tsx b/apps/web/src/components/ui/components/Stepper.test.tsxnew file mode 100644index 0000000000..ba5600802e--- /dev/null+++ b/apps/web/src/components/ui/components/Stepper.test.tsx@@ -0,0 +1,40 @@+import { cleanup, render, screen, waitFor } from '@solidjs/testing-library';+import { createSignal } from 'solid-js';+import { afterEach, describe, expect, it } from 'vitest';+import { Stepper } from './Stepper';++afterEach(cleanup);++describe('Stepper', () => {+ it('finishes an outin step change while detached by an ancestor Suspense', async () => {+ const [step, setStep] = createSignal(0);+ const { container } = render(() => (+ <Stepper step={step()} transition={Stepper.transitions.scale}>+ <Stepper.Step>+ <p>Step one</p>+ </Stepper.Step>+ <Stepper.Step>+ <p>Step two</p>+ </Stepper.Step>+ </Stepper>+ ));+ expect(screen.getByText('Step one')).toBeTruthy();++ // A suspending ancestor pulls its subtree out of the document, where CSS+ // transitions never run and so never emit transitionend.+ const host = container.parentNode as ParentNode;+ container.remove();+ setStep(1);++ await waitFor(() => {+ expect(container.textContent).toContain('Step two');+ expect(container.textContent).not.toContain('Step one');+ });++ host.appendChild(container);+ const slot = screen.getByText('Step two').parentElement as HTMLElement;+ await waitFor(() => {+ expect(slot.className).not.toMatch(/opacity-0|transition-all/);+ });+ });+});diff --git a/apps/web/src/components/ui/components/Stepper.tsx b/apps/web/src/components/ui/components/Stepper.tsxindex 3f6745a005..0b124cea2e 100644--- a/apps/web/src/components/ui/components/Stepper.tsx+++ b/apps/web/src/components/ui/components/Stepper.tsx@@ -83,6 +83,35 @@ const SCALE: StepperTransition = {exitToClass: 'opacity-0 scale-95',};+const nextFrame = (fn: () => void) =>+ requestAnimationFrame(() => requestAnimationFrame(fn));++const classList = (value?: string) => value?.split(' ').filter(Boolean) ?? [];++/* Runs one enter/exit class swap and reports completion once the node's own+ animations settle. Waiting on `transitionend` instead wedges an outin swap+ forever whenever nothing animates: a node detached by an ancestor+ <Suspense>, or a swap that changes no computed value. getAnimations()+ flushes style, so it sees exactly the transitions the swap started, and+ none in those cases. */+function animate(+ el: Element,+ from: string[],+ active: string[],+ to: string[],+ done: () => void+) {+ el.classList.add(...from, ...active);+ nextFrame(async () => {+ el.classList.remove(...from);+ el.classList.add(...to);+ const running = el.getAnimations?.() ?? [];+ await Promise.allSettled(running.map((a) => a.finished));+ el.classList.remove(...active, ...to);+ done();+ });+}+/* Same trick as solid-js's Match: returning the props object lets the parentStepper read `index`/`children` without evaluating the JSX subtree. Solid'sJSX compiler keeps `children` as a getter, so it stays lazy until the@@ -150,15 +179,29 @@ function StepperRoot(props: StepperProps) {</Show>}>+ {/* Two-argument hooks take the class swap over from the library,+ which only sequences the switch. */}<Transitionappear={props.appear}mode={transition().mode}- enterActiveClass={transition().enterActiveClass}- enterClass={transition().enterClass}- enterToClass={transition().enterToClass}- exitActiveClass={transition().exitActiveClass}- exitClass={transition().exitClass}- exitToClass={transition().exitToClass}+ onEnter={(el, done) =>+ animate(+ el,+ classList(transition().enterClass),+ classList(transition().enterActiveClass),+ classList(transition().enterToClass),+ done+ )+ }+ onExit={(el, done) =>+ animate(+ el,+ classList(transition().exitClass),+ classList(transition().exitActiveClass),+ classList(transition().exitToClass),+ done+ )+ }><Show when={activeStep()} keyed>{(step) => slot(step)}