@@ -218,9 +218,9 @@ function SolutionEventList({
218
218
return [ ] ;
219
219
}
220
220
221
- // For 3 or fewer items, find the first highlighted item or default to first item
221
+ // For 3 or fewer items, find the first highlighted and active item or default to first item
222
222
const firstHighlightedIndex = events . findIndex (
223
- event => event . is_most_important_event
223
+ event => event . is_most_important_event && event . is_active !== false
224
224
) ;
225
225
return [ firstHighlightedIndex === - 1 ? 0 : firstHighlightedIndex ] ;
226
226
} ) ;
@@ -231,6 +231,20 @@ function SolutionEventList({
231
231
) ;
232
232
} , [ ] ) ;
233
233
234
+ // Wrap onToggleActive to also handle expanded state
235
+ const handleToggleActive = useCallback (
236
+ ( index : number ) => {
237
+ onToggleActive ( index ) ;
238
+ // If we're disabling an item (toggling from active to inactive),
239
+ // we need to remove it from expanded items
240
+ const event = events [ index ] ;
241
+ if ( event && event . is_active !== false ) {
242
+ setExpandedItems ( current => current . filter ( i => i !== index ) ) ;
243
+ }
244
+ } ,
245
+ [ events , onToggleActive ]
246
+ ) ;
247
+
234
248
if ( ! events ?. length ) {
235
249
return null ;
236
250
}
@@ -243,12 +257,23 @@ function SolutionEventList({
243
257
const isExpanded = expandedItems . includes ( index ) ;
244
258
const isHumanAction = event . timeline_item_type === 'human_instruction' ;
245
259
260
+ const handleItemClick = ( ) => {
261
+ if ( ! isSelected ) {
262
+ // If item is disabled, re-enable it instead of toggling expansion
263
+ handleToggleActive ( index ) ;
264
+ return ;
265
+ }
266
+ if ( ! isHumanAction && event . code_snippet_and_analysis ) {
267
+ toggleItem ( index ) ;
268
+ }
269
+ } ;
270
+
246
271
return (
247
272
< Timeline . Item
248
273
key = { index }
249
274
title = {
250
275
< StyledTimelineHeader
251
- onClick = { ( ) => toggleItem ( index ) }
276
+ onClick = { handleItemClick }
252
277
isActive = { isActive }
253
278
isSelected = { isSelected }
254
279
data-test-id = { `autofix-solution-timeline-item-${ index } ` }
@@ -259,7 +284,7 @@ function SolutionEventList({
259
284
} }
260
285
/>
261
286
< IconWrapper >
262
- { ! isHumanAction && event . code_snippet_and_analysis && (
287
+ { ! isHumanAction && event . code_snippet_and_analysis && isSelected && (
263
288
< StyledIconChevron
264
289
direction = { isExpanded ? 'down' : 'right' }
265
290
size = "xs"
@@ -272,7 +297,7 @@ function SolutionEventList({
272
297
if ( isHumanAction ) {
273
298
onDeleteItem ( index ) ;
274
299
} else {
275
- onToggleActive ( index ) ;
300
+ handleToggleActive ( index ) ;
276
301
}
277
302
} }
278
303
aria-label = { isSelected ? t ( 'Deselect item' ) : t ( 'Select item' ) }
0 commit comments