@@ -94,7 +94,7 @@ const Accordion: FC<IAccordionProps> = ({
94
94
. map ( ( section , idx ) => (
95
95
< div
96
96
key = { section . id }
97
- draggable = { hasDraggableSections }
97
+ draggable = { hasDraggableSections && section . items . length > 0 }
98
98
onDrag = { e => handleDrag ( e , section ) }
99
99
onDragOver = { ( ) =>
100
100
hasDraggableSections && setDraggedOverId ( section . id )
@@ -178,46 +178,52 @@ const Accordion: FC<IAccordionProps> = ({
178
178
179
179
{ expanded . includes ( section . id ) && (
180
180
< >
181
- < DraggableList
182
- items = { section . items }
183
- onClick = { ( item : IDraggableListItem ) => {
184
- onSectionItemClick ?.( item ) ;
185
- onSelected ?.( item ) ;
186
- setSelectedItemId ( item . id ) ;
187
- setSelectedSectionId ( null ) ;
188
- } }
189
- onDragged = { ( items : IDraggableListItem [ ] ) => {
190
- onSorted ?.(
191
- AccordionOrderType . LECTURES ,
192
- [
193
- ...sections . map ( s =>
194
- s . id === section . id ? { ...s , items } : s
195
- )
196
- ] ,
197
- { sectionId : section . id , items }
198
- ) ;
199
- } }
200
- isDraggable = { hasDraggableSectionItems }
201
- className = 'yl:gap-4 yl:flex yl:flex-col yl:py-4'
202
- draggedOverClassName = 'yl:border-t-2 yl:border-border'
203
- liClassName = { ( item : IDraggableListItem ) =>
204
- classNames (
205
- "yl:cursor-default yl:break-words yl:leading-normal yl:px-4" ,
206
- {
207
- "yl:hover:cursor-pointer yl:hover:text-primary" :
208
- onSectionItemClick ,
209
- "yl:text-primary" :
210
- onSectionItemClick && selectedItemId === item . id ,
211
- "yl:pl-5" : section . items . length === 1
212
- }
213
- )
214
- }
215
- />
181
+ { section . items . length > 0 && (
182
+ < DraggableList
183
+ items = { section . items }
184
+ onClick = { ( item : IDraggableListItem ) => {
185
+ onSectionItemClick ?.( item ) ;
186
+ onSelected ?.( item ) ;
187
+ setSelectedItemId ( item . id ) ;
188
+ setSelectedSectionId (
189
+ sections . find ( s => s . items . includes ( item ) ) ?. id ?? null
190
+ ) ;
191
+ } }
192
+ onDragged = { ( items : IDraggableListItem [ ] ) => {
193
+ onSorted ?.(
194
+ AccordionOrderType . LECTURES ,
195
+ [
196
+ ...sections . map ( s =>
197
+ s . id === section . id ? { ...s , items } : s
198
+ )
199
+ ] ,
200
+ { sectionId : section . id , items }
201
+ ) ;
202
+ } }
203
+ isDraggable = {
204
+ hasDraggableSectionItems && section . items . length > 0
205
+ }
206
+ className = 'yl:gap-4 yl:flex yl:flex-col yl:py-4'
207
+ draggedOverClassName = 'yl:border-t-2 yl:border-border'
208
+ liClassName = { ( item : IDraggableListItem ) =>
209
+ classNames (
210
+ "yl:cursor-default yl:break-words yl:leading-normal yl:px-4" ,
211
+ {
212
+ "yl:hover:cursor-pointer yl:hover:text-primary" :
213
+ onSectionItemClick ,
214
+ "yl:text-primary" :
215
+ onSectionItemClick && selectedItemId === item . id ,
216
+ "yl:pl-5" : section . items . length === 1
217
+ }
218
+ )
219
+ }
220
+ />
221
+ ) }
216
222
{ onAddSectionItem && (
217
223
< div
218
224
onClick = { ( ) => onAddSectionItem ( section ) }
219
225
className = { classNames (
220
- "yl:group yl:border-border yl:hover:bg-text/2 yl:cursor-pointer"
226
+ "yl:group yl:border-border yl:hover:bg-text/1 yl:cursor-pointer yl:bg-text/3 "
221
227
) }
222
228
role = 'presentation'
223
229
>
@@ -250,7 +256,7 @@ const Accordion: FC<IAccordionProps> = ({
250
256
< div
251
257
onClick = { onAddSection }
252
258
className = { classNames (
253
- "yl:group yl:border-2 yl:border-t-0 yl:border-border yl:hover:bg-text/2 yl:rounded-bl-md yl:rounded-br-md yl:cursor-pointer"
259
+ "yl:group yl:border-2 yl:border-t-0 yl:border-border yl:hover:bg-text/2 yl:rounded-bl-md yl:rounded-br-md yl:cursor-pointer yl:bg-text/3 "
254
260
) }
255
261
role = 'presentation'
256
262
>
0 commit comments