Skip to content

Commit 64ccc20

Browse files
fix(headless): measure flow steps without parent transforms (#9726)
Co-authored-by: Alex Carpenter <alex.carpenter@clerk.dev>
1 parent 4e1e432 commit 64ccc20

3 files changed

Lines changed: 6 additions & 15 deletions

File tree

‎.changeset/quiet-flow-dialog.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

‎packages/headless/src/primitives/flow/flow-root.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const FlowRoot = React.forwardRef<HTMLDivElement, FlowRootProps>(function
3131
}
3232

3333
const measure = () => {
34-
setActiveStepHeight(activeStep.getBoundingClientRect().height);
34+
setActiveStepHeight(activeStep.offsetHeight);
3535
};
3636

3737
measure();

‎packages/headless/src/primitives/flow/flow.test.tsx‎

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -212,21 +212,10 @@ describe('Flow', () => {
212212
});
213213

214214
it('publishes the entering step height without enabling initial animation', () => {
215-
const getBoundingClientRect = vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(function (
215+
const offsetHeight = vi.spyOn(HTMLElement.prototype, 'offsetHeight', 'get').mockImplementation(function (
216216
this: HTMLElement,
217217
) {
218-
const height = this.dataset.testid === 'password-step' ? 120 : 240;
219-
return {
220-
x: 0,
221-
y: 0,
222-
width: 420,
223-
height,
224-
top: 0,
225-
right: 420,
226-
bottom: height,
227-
left: 0,
228-
toJSON: () => ({}),
229-
};
218+
return this.dataset.testid === 'password-step' ? 120 : 240;
230219
});
231220
const { rerender } = render(<TestFlow value='password' />);
232221
const root = screen.getByTestId('flow-root');
@@ -242,6 +231,6 @@ describe('Flow', () => {
242231

243232
expect(root.style.getPropertyValue('--cl-flow-step-height')).toBe('240px');
244233
expect(root).not.toHaveAttribute('data-initial');
245-
getBoundingClientRect.mockRestore();
234+
offsetHeight.mockRestore();
246235
});
247236
});

0 commit comments

Comments
 (0)