Skip to content

Commit 776b8d0

Browse files
fix: consume getHiddenHeight inside of component$
1 parent 9b1cb09 commit 776b8d0

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/kit-headless/src/components/collapsible/collapsible.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ import {
1010
type QRL,
1111
useTask$,
1212
} from '@builder.io/qwik';
13+
1314
import { collapsibleContextId } from './collapsible-context-id';
1415
import { type CollapsibleContext } from './collapsible-context.type';
1516
import { isBrowser } from '@builder.io/qwik/build';
16-
import { getHiddenHeight } from '../../utils/get-hidden-height';
17+
import { useCollapsible } from './use-collapsible';
1718

1819
export type CollapsibleProps = PropsOf<'div'> & {
1920
id?: string;
@@ -51,6 +52,8 @@ export const HCollapsible = component$((props: CollapsibleProps) => {
5152

5253
const contentHeightSig = useSignal<number | null>(null);
5354

55+
const { getHiddenHeight } = useCollapsible();
56+
5457
const localId = useId();
5558
const itemId = id ?? localId;
5659

@@ -72,7 +75,7 @@ export const HCollapsible = component$((props: CollapsibleProps) => {
7275
}
7376

7477
if (contentHeightSig.value === null) {
75-
contentHeightSig.value = getHiddenHeight(contentRef.value);
78+
contentHeightSig.value = await getHiddenHeight(contentRef.value);
7679
}
7780

7881
if (contentHeightSig.value !== 0) {

packages/kit-headless/src/components/collapsible/use-collapsible.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export function useCollapsible() {
1616

1717
el.after(clone);
1818
const height = clone.offsetHeight;
19-
console.log('height', height);
2019

2120
clone.remove();
2221

0 commit comments

Comments
 (0)