This repository was archived by the owner on Sep 20, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +14
-16
lines changed
packages/vue-composables/src Expand file tree Collapse file tree 1 file changed +14
-16
lines changed Original file line number Diff line number Diff line change @@ -50,39 +50,37 @@ export function useDisclosure(props: UseDisclosureProps = {}) {
50
50
const onToggle = ( ) => ( isOpen . value ? onClose ( ) : onOpen ( ) )
51
51
52
52
/**
53
- * Ref object containing the HTML attributes for the button that
53
+ * Computed object containing the HTML attributes for the button that
54
54
* is triggering the disclosure state
55
55
*
56
56
* `NOTE:` Pass this to the v-bind of the element.
57
57
*
58
58
* i.e. `v-bind='buttonProps'`
59
59
*/
60
- const buttonProps = ref < HTMLAttributes > ( )
60
+
61
+ const buttonProps = computed ( ( ) => ( {
62
+ "aria-expanded" : isOpen . value ,
63
+ "aria-controls" : id . value ,
64
+ onClick ( ) {
65
+ onToggle ( )
66
+ } ,
67
+ } ) )
61
68
62
69
/**
63
- * Ref object containing the HTML attributes for the element that
70
+ * Computed object containing the HTML attributes for the element that
64
71
* is being effected by the disclosure state.
65
72
*
66
73
* `NOTE:` Pass this to the v-bind of the element.
67
74
*
68
75
* i.e. `v-bind='disclosureProps'`
69
76
*/
70
- const disclosureProps = ref < HTMLAttributes > ( )
77
+ const disclosureProps = computed ( ( ) => ( {
78
+ hidden : ! isOpen . value ,
79
+ id : id . value ,
80
+ } ) )
71
81
72
82
watchEffect ( ( ) => {
73
83
isOpen . value = isOpenState . value
74
- buttonProps . value = {
75
- "aria-expanded" : isOpen . value ,
76
- "aria-controls" : id . value ,
77
- onClick ( ) {
78
- onToggle ( )
79
- } ,
80
- }
81
-
82
- disclosureProps . value = {
83
- hidden : ! isOpen . value ,
84
- id : id . value ,
85
- }
86
84
} )
87
85
88
86
return {
You can’t perform that action at this time.
0 commit comments