@@ -103,17 +103,21 @@ const Accordion: FC<IAccordionProps> = ({
103103 role = 'presentation'
104104 >
105105 < h3
106- onClick = { ( ) => {
106+ onClick = { e => {
107+ e . stopPropagation ( ) ;
108+ e . preventDefault ( ) ;
107109 setSelectedSectionId ( section . id ) ;
108110 } }
109111 className = { classNames (
110- "yl-relative yl-flex yl-cursor-pointer yl-select-none yl-items-center yl-font-semibold yl-capitalize yl-p-4" ,
112+ "yl-relative yl-flex yl-cursor-default yl-select-none yl-items-center yl-font-semibold yl-capitalize yl-p-4" ,
111113 sectionTitleClassName ,
112114 {
113115 "yl-bg-primary-text-color/5" : expanded . includes ( section . id ) ,
116+ "yl-cursor-pointer" : onSectionItemClick ,
114117 "yl-text-primary-text-color" :
115- selectedSectionId !== section . id ,
116- "yl-text-primary" : selectedSectionId === section . id
118+ selectedSectionId !== section . id || ! onSectionItemClick ,
119+ "yl-text-primary" :
120+ onSectionItemClick && selectedSectionId === section . id
117121 }
118122 ) }
119123 onKeyDown = { e =>
@@ -160,6 +164,11 @@ const Accordion: FC<IAccordionProps> = ({
160164 { expanded . includes ( section . id ) && (
161165 < DraggableList
162166 items = { section . items }
167+ onClick = { ( item : IDraggableListItem ) => {
168+ onSectionItemClick ?.( item ) ;
169+ onSelected ?.( item ) ;
170+ setSelectedItemId ( item . id ) ;
171+ } }
163172 onDragged = { ( items : IDraggableListItem [ ] ) => {
164173 setSections (
165174 [
@@ -185,12 +194,6 @@ const Accordion: FC<IAccordionProps> = ({
185194 }
186195 )
187196 }
188- onClick = { ( item : IDraggableListItem ) => {
189- onSectionItemClick ?.( item ) ;
190- onSelected ?.( item ) ;
191- setSelectedItemId ( item . id ) ;
192- setSelectedSectionId ( section . id ) ;
193- } }
194197 />
195198 ) }
196199 </ div >
0 commit comments