@@ -77,10 +77,10 @@ function FocusablePartGroupingActivity(props: FocusablePartGroupingActivityProps
7777 [ groupKey , focusByGroupKey ]
7878 ) ;
7979
80- // When a child of the activity receives focus, notify the transcript to set the `aria-activedescendant` to this activity.
80+ // When a child of the group receives focus, notify the transcript to set the `aria-activedescendant` to this activity.
8181 const handleDescendantFocus : ( ) => void = useCallback ( ( ) => focusSelf ( false ) , [ focusSelf ] ) ;
8282
83- // When receive Escape key from descendant, focus back to the activity .
83+ // When receive Escape key from descendant, focus back to the group .
8484 const handleLeaveFocusTrap = useCallback ( ( ) => focusSelf ( ) , [ focusSelf ] ) ;
8585
8686 const isActiveDescendant = groupingActivityDescendantId === activeDescendantId ;
@@ -118,32 +118,30 @@ function PartGroupingActivity(props: PartGroupingActivityProps) {
118118 const getKeyByActivity = useGetKeyByActivity ( ) ;
119119 const [ isGroupOpen , setIsGroupOpen ] = useState ( true ) ;
120120
121+ const messages = useMemo (
122+ ( ) => activities . map ( activity => getOrgSchemaMessage ( activity . entities ) ) . filter ( message => ! ! message ) ,
123+ [ activities ]
124+ ) ;
125+ // eslint-disable-next-line no-magic-numbers
126+ const lastMessage = messages . at ( - 1 ) ;
127+
121128 const activityKeys = useMemo (
122129 ( ) => activities . map ( activity => getKeyByActivity ( activity ) ) ,
123130 [ activities , getKeyByActivity ]
124131 ) ;
125132
126133 const { shouldSkipRender } = usePartGroupingLogicalGroup ( {
127134 activityKeys,
128- isGroupOpen
135+ isCollapsed : ! isGroupOpen
129136 } ) ;
130137
131138 const firstActivity = activities . at ( 0 ) ;
132139 // eslint-disable-next-line no-magic-numbers
133140 const lastActivity = activities . at ( - 1 ) ;
134141
135- const lastMessage = useMemo (
136- ( ) =>
137- getOrgSchemaMessage (
138- (
139- activities
140- . toReversed ( )
141- . find (
142- activity => 'streamType' in activity . channelData && activity . channelData . streamType === 'informative'
143- ) || lastActivity
144- ) ?. entities
145- ) ,
146- [ activities , lastActivity ]
142+ const currentMessage = useMemo (
143+ ( ) => messages . toReversed ( ) . find ( message => message . creativeWorkStatus === 'incomplete' ) || lastMessage ,
144+ [ messages , lastMessage ]
147145 ) ;
148146
149147 const { renderAvatar, showCallout } = useRenderActivityProps ( firstActivity ) ;
@@ -170,7 +168,7 @@ function PartGroupingActivity(props: PartGroupingActivityProps) {
170168 topCallout = { topAlignedCallout }
171169 >
172170 < StackedLayoutMain avatar = { showAvatar && renderAvatar && renderAvatar ( ) } >
173- < CollapsibleGrouping isOpen = { isGroupOpen } onToggle = { setIsGroupOpen } title = { lastMessage ?. abstract || '' } >
171+ < CollapsibleGrouping isOpen = { isGroupOpen } onToggle = { setIsGroupOpen } title = { currentMessage ?. abstract || '' } >
174172 < TranscriptActivityList > { children } </ TranscriptActivityList >
175173 </ CollapsibleGrouping >
176174 </ StackedLayoutMain >
0 commit comments