@@ -30,22 +30,26 @@ import { ActivityInteractionsContext } from '../../burning/ActivityInteractionsC
30
30
* Renders the Activity component with associated heading and body, managing interactivity and state.
31
31
*
32
32
* @param {Object } props - Object containing all properties required by the Activity component.
33
- * @param {(evt: MouseEvent) => void } props.didClick - Callback function triggered when the root element is clicked.
34
33
* @param {Expansion } props.expansion - String indicating the expansion state of the activity, such as 'expanded' or 'collapsed'.
35
34
* @param {() => void } props.toggle - Callback function to handle the expansion/collapse action.
36
35
* @param {number } props.trackerCount - Object representing the tracker count for the activity.
37
36
* @param {number } props.itemCount - Object representing the count of items in the activity.
38
37
* @param {boolean } props.batched - Boolean indicating whether the activity uses batched loading.
39
38
* @param {import("preact").ComponentChild } [props.children]
40
39
*/
41
- export function Activity ( { didClick , expansion, toggle, trackerCount, itemCount, batched, children } ) {
40
+ export function Activity ( { expansion, toggle, trackerCount, itemCount, batched, children } ) {
42
41
// see: https://www.w3.org/WAI/ARIA/apg/patterns/accordion/examples/accordion/
43
42
const expanded = expansion === 'expanded' ;
44
43
const WIDGET_ID = useId ( ) ;
45
44
const TOGGLE_ID = useId ( ) ;
45
+ const { didClick } = useContext ( ActivityInteractionsContext ) ;
46
+
47
+ const ref = useRef ( null ) ;
48
+ useOnMiddleClick ( ref , didClick ) ;
49
+
46
50
return (
47
51
< Fragment >
48
- < div class = { styles . root } onClick = { didClick } >
52
+ < div class = { styles . root } onClick = { didClick } ref = { ref } >
49
53
< ActivityHeading
50
54
trackerCount = { trackerCount }
51
55
itemCount = { itemCount }
@@ -240,10 +244,6 @@ export function ActivityConfigured({ expansion, toggle, children }) {
240
244
const batched = useBatchedActivityApi ( ) ;
241
245
242
246
const { activity } = useContext ( NormalizedDataContext ) ;
243
- const { didClick } = useContext ( ActivityInteractionsContext ) ;
244
-
245
- const ref = useRef ( /** @type {HTMLUListElement|null } */ ( null ) ) ;
246
- useOnMiddleClick ( ref , didClick ) ;
247
247
248
248
const count = useComputed ( ( ) => {
249
249
return activity . value . totalTrackers ;
@@ -254,14 +254,7 @@ export function ActivityConfigured({ expansion, toggle, children }) {
254
254
} ) ;
255
255
256
256
return (
257
- < Activity
258
- batched = { batched }
259
- itemCount = { itemCount . value }
260
- trackerCount = { count . value }
261
- expansion = { expansion }
262
- toggle = { toggle }
263
- didClick = { didClick }
264
- >
257
+ < Activity batched = { batched } itemCount = { itemCount . value } trackerCount = { count . value } expansion = { expansion } toggle = { toggle } >
265
258
{ children }
266
259
</ Activity >
267
260
) ;
0 commit comments