@@ -16,12 +16,13 @@ const Accordion: FC<IAccordionProps> = ({
1616 setSections,
1717 sectionTitleClassName,
1818 onSectionItemClick,
19+ onSectionClick,
1920 onSelected,
2021 expanded,
2122 setExpanded,
2223 selectedId,
2324 hasDraggableSections,
24- hasDraggableSetionItems
25+ hasDraggableSectionItems
2526} ) => {
2627 const [ selectedItemId , setSelectedItemId ] = useState <
2728 number | null | undefined
@@ -70,7 +71,8 @@ const Accordion: FC<IAccordionProps> = ({
7071 { sections . map ( ( section , idx ) => (
7172 < div
7273 key = { section . id }
73- draggable = { hasDraggableSections && sections . length > 1 }
74+ onClick = { ( ) => onSectionClick ?.( section ) }
75+ draggable = { hasDraggableSections }
7476 onDrag = { e => handleDrag ( e , section ) }
7577 onDragOver = { ( ) =>
7678 hasDraggableSections && setDraggedOverId ( section . id )
@@ -94,7 +96,7 @@ const Accordion: FC<IAccordionProps> = ({
9496 >
9597 < h3
9698 className = { classNames (
97- "yl-relative yl-flex yl-cursor-pointer yl-select-none yl-items-center yl-font-semibold yl-capitalize yl-text-primary-text-color yl-py-2 yl-pl-2 yl-pr-8 " ,
99+ "yl-relative yl-flex yl-cursor-pointer yl-select-none yl-items-center yl-font-semibold yl-capitalize yl-text-primary-text-color yl-p-4 " ,
98100 sectionTitleClassName ,
99101 { "yl-bg-primary-text-color/5" : expanded . includes ( section . id ) }
100102 ) }
@@ -106,7 +108,7 @@ const Accordion: FC<IAccordionProps> = ({
106108 role = 'button'
107109 aria-expanded = { expanded . includes ( section . id ) }
108110 >
109- { hasDraggableSetionItems && (
111+ { hasDraggableSections && (
110112 < div >
111113 < IconDrag className = 'yl-w-6 yl-opacity-50 yl-mr-1' />
112114 </ div >
@@ -136,16 +138,17 @@ const Accordion: FC<IAccordionProps> = ({
136138 )
137139 ] ) ;
138140 } }
139- isDraggable = { hasDraggableSetionItems }
141+ isDraggable = { hasDraggableSectionItems }
140142 className = 'yl-gap-4 yl-flex yl-flex-col yl-py-4'
141143 draggedOverClassName = 'yl-border-t-2 yl-border-primary'
142144 liClassName = { ( item : IDraggableListItem ) =>
143145 classNames (
144- "hover:text-primary cursor-pointer break-all leading-normal yl-px-2 " ,
146+ "yl-cursor-default hover:text-primary break-all leading-normal yl-px-4 " ,
145147 {
146148 "yl-cursor-pointer" : onSectionItemClick ,
147149 "yl-text-primary-text-color" : selectedItemId !== item . id ,
148- "yl-text-primary" : selectedItemId === item . id ,
150+ "yl-text-primary" :
151+ onSectionItemClick && selectedItemId === item . id ,
149152 "yl-pl-9" : section . items . length === 1
150153 }
151154 )
0 commit comments