@@ -3,8 +3,8 @@ import { computed } from 'vue'
33import { useDirection } from ' ../direction/Direction.ts'
44import { useControllableState , useForwardElement , useId , useRef } from ' ../hooks/index.ts'
55import { Primitive } from ' ../primitive/index.ts'
6- import { composeEventHandlers } from ' ../utils/vue.ts'
76import { arrayify } from ' ../utils/array.ts'
7+ import { composeEventHandlers } from ' ../utils/vue.ts'
88import { ACCORDION_KEYS , type AccordionRootEmits , type AccordionRootProps , type AccordionType , Collection , provideAccordionContext , useCollection } from ' ./AccordionRoot.ts'
99
1010type SingleValue = Exclude <AccordionRootProps <' single' >[' value' ], undefined >
@@ -34,13 +34,17 @@ const collectionContext = Collection.provideCollectionContext($el)
3434const getItems = useCollection (collectionContext )
3535
3636const onKeydown = composeEventHandlers <KeyboardEvent >((event ) => {
37+ if (props .disabled )
38+ return
3739 emit (' keydown' , event )
3840}, (event ) => {
41+ if (props .disabled )
42+ return
3943 if (! ACCORDION_KEYS .includes (event .key ))
4044 return
4145 const target = event .target as HTMLElement
42- const triggerCollection = getItems ().filter (item => ! item .ref . disabled )
43- const triggerIndex = triggerCollection .findIndex (item => item . ref === target )
46+ const triggerCollection = getItems ().filter (item => ! item .disabled )
47+ const triggerIndex = triggerCollection .findIndex (item => item === target )
4448 const triggerCount = triggerCollection .length
4549
4650 if (triggerIndex === - 1 )
@@ -107,7 +111,7 @@ const onKeydown = composeEventHandlers<KeyboardEvent>((event) => {
107111 }
108112
109113 const clampedIndex = nextIndex % triggerCount
110- triggerCollection [clampedIndex ]?.ref . focus ()
114+ triggerCollection [clampedIndex ]?.focus ()
111115})
112116
113117provideAccordionContext ({
@@ -149,10 +153,7 @@ provideAccordionContext({
149153 <Primitive
150154 :ref =" forwardElement"
151155 :data-orientation =" orientation"
152- data-root
153- v-bind =" {
154- onKeydown: props.disabled ? undefined : onKeydown,
155- }"
156+ @keydown =" onKeydown"
156157 >
157158 <slot />
158159 </Primitive >
0 commit comments