11import { reactNode } from '@msinternal/botframework-webchat-react-valibot' ;
22import { hooks } from 'botframework-webchat-api' ;
33import { getOrgSchemaMessage , type WebChatActivity } from 'botframework-webchat-core' ;
4- import React , { memo , useCallback , useMemo , useState } from 'react' ;
4+ import React , { memo , useCallback , useMemo , useState , type MouseEventHandler } from 'react' ;
55import {
66 any ,
77 array ,
@@ -94,6 +94,11 @@ function FocusablePartGroupingActivity(props: FocusablePartGroupingActivityProps
9494 // When receive Escape key from descendant, focus back to the group.
9595 const handleLeaveFocusTrap = useCallback ( ( ) => focusSelf ( ) , [ focusSelf ] ) ;
9696
97+ // When the user press UP/DOWN arrow keys, we put a visual focus indicator around the focused group.
98+ // We should do the same for mouse, when the user click on the activity, we should also put a visual focus indicator around the activity.
99+ // We are doing it in event capture phase to prevent descendants from stopping event propagation to us.
100+ const handleMouseDownCapture : MouseEventHandler = useCallback ( ( ) => focusSelf ( false ) , [ focusSelf ] ) ;
101+
97102 const isActiveDescendant = groupingActivityDescendantId === activeDescendantId ;
98103
99104 const activityElementMapRef = useActivityElementMapRef ( ) ;
@@ -108,7 +113,11 @@ function FocusablePartGroupingActivity(props: FocusablePartGroupingActivityProps
108113 ) ;
109114
110115 return (
111- < TranscriptFocusContent focused = { isActiveDescendant } ref = { groupCallbackRef } >
116+ < TranscriptFocusContent
117+ focused = { isActiveDescendant }
118+ onMouseDownCapture = { handleMouseDownCapture }
119+ ref = { groupCallbackRef }
120+ >
112121 < FocusTrap
113122 onFocus = { handleDescendantFocus }
114123 onLeave = { handleLeaveFocusTrap }
0 commit comments