File tree Expand file tree Collapse file tree 3 files changed +10
-5
lines changed
packages/kit-headless/src/components Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,8 @@ type RootProps = QwikIntrinsicElements['div'] & {
29
29
} ;
30
30
31
31
export const Root = component$ ( ( { use, ...props } : RootProps ) => {
32
- const provider = use || useCarousel ( ) ;
32
+ const carouselState = useCarousel ( ) ;
33
+ const provider = use || carouselState ;
33
34
useCarouselProvider ( provider ) ;
34
35
35
36
return (
@@ -124,7 +125,8 @@ export const controlContext = createContextId<ControlContext>(
124
125
) ;
125
126
126
127
export const Controls = component$ ( ( props : ControlsProps ) => {
127
- const controlService = { id : props . id || useId ( ) } ;
128
+ const uniqueId = useId ( ) ;
129
+ const controlService = { id : props . id || uniqueId } ;
128
130
const { pages } = useContext ( carouselContext ) ;
129
131
useContextProvider ( controlContext , controlService ) ;
130
132
Original file line number Diff line number Diff line change @@ -37,9 +37,11 @@ export type Params = {
37
37
} ;
38
38
39
39
export const useCarousel = ( params : Params | void ) : CarouselContext => {
40
+ const generatedId = useId ( ) ;
41
+ const newRef = useSignal ( undefined ) ;
40
42
const defaultParams = {
41
- id : params ?. id || useId ( ) ,
42
- ref : params ?. ref || useSignal ( ) ,
43
+ id : params ?. id || generatedId ,
44
+ ref : params ?. ref || newRef ,
43
45
startAt : params ?. startAt ?? 0 ,
44
46
loop : params ?. loop ?? true ,
45
47
transition : params ?. transition ?? 350 ,
Original file line number Diff line number Diff line change @@ -31,9 +31,10 @@ type ControlProps = QwikIntrinsicElements['div'] & {
31
31
} ;
32
32
33
33
export const Root = component$ ( ( props : ControlProps ) => {
34
+ const uniqueId = useId ( ) ;
34
35
const contextService : InputContextService = {
35
36
ref : useSignal < HTMLInputElement > ( ) ,
36
- id : props . id || useId ( ) ,
37
+ id : props . id || uniqueId ,
37
38
} ;
38
39
useContextProvider ( inputContext , contextService ) ;
39
40
You can’t perform that action at this time.
0 commit comments