1- import React , { type CSSProperties , memo , useCallback } from 'react' ;
1+ import React , { type CSSProperties , memo } from 'react' ;
22import type GridMetrics from './GridMetrics' ;
33import type GridModel from './GridModel' ;
44
@@ -7,8 +7,6 @@ export interface GridAccessibilityLayerProps {
77 metrics : GridMetrics | null ;
88 /** The model providing cell data */
99 model : GridModel ;
10- /** Reference to the canvas element for dispatching click events */
11- canvasRef : HTMLCanvasElement | null ;
1210}
1311
1412const containerStyle : CSSProperties = {
@@ -22,7 +20,7 @@ const cellStyle: CSSProperties = {
2220 position : 'absolute' ,
2321 opacity : 0 ,
2422 overflow : 'hidden' ,
25- pointerEvents : 'auto ' ,
23+ pointerEvents : 'none ' ,
2624} ;
2725
2826/**
@@ -35,77 +33,12 @@ const cellStyle: CSSProperties = {
3533 * - Column headers with `data-testid="grid-column-header-{column}-{depth}"`
3634 * - Row headers with `data-testid="grid-row-header-{row}"`
3735 *
38- * Clicks on accessibility elements are forwarded to the underlying canvas at the
39- * corresponding coordinates, triggering normal grid mouse handling.
36+ * All elements have pointer-events: none so clicks pass through to the underlying canvas.
4037 */
4138function GridAccessibilityLayer ( {
4239 metrics,
4340 model,
44- canvasRef,
4541} : GridAccessibilityLayerProps ) : JSX . Element | null {
46- const forwardMouseEvent = useCallback (
47- ( event : React . MouseEvent < HTMLDivElement > , eventType : string ) => {
48- if ( ! canvasRef ) return ;
49-
50- // Get the center of the clicked element
51- const rect = event . currentTarget . getBoundingClientRect ( ) ;
52- const clientX = rect . left + rect . width / 2 ;
53- const clientY = rect . top + rect . height / 2 ;
54-
55- // Dispatch a synthetic mouse event to the canvas at the cell's position
56- const syntheticEvent = new MouseEvent ( eventType , {
57- bubbles : true ,
58- cancelable : true ,
59- clientX,
60- clientY,
61- button : event . button ,
62- buttons : event . buttons ,
63- ctrlKey : event . ctrlKey ,
64- shiftKey : event . shiftKey ,
65- altKey : event . altKey ,
66- metaKey : event . metaKey ,
67- } ) ;
68-
69- canvasRef . dispatchEvent ( syntheticEvent ) ;
70- } ,
71- [ canvasRef ]
72- ) ;
73-
74- const handleClick = useCallback (
75- ( event : React . MouseEvent < HTMLDivElement > ) => {
76- forwardMouseEvent ( event , 'click' ) ;
77- } ,
78- [ forwardMouseEvent ]
79- ) ;
80-
81- const handleDoubleClick = useCallback (
82- ( event : React . MouseEvent < HTMLDivElement > ) => {
83- forwardMouseEvent ( event , 'dblclick' ) ;
84- } ,
85- [ forwardMouseEvent ]
86- ) ;
87-
88- const handleContextMenu = useCallback (
89- ( event : React . MouseEvent < HTMLDivElement > ) => {
90- forwardMouseEvent ( event , 'contextmenu' ) ;
91- } ,
92- [ forwardMouseEvent ]
93- ) ;
94-
95- const handleMouseDown = useCallback (
96- ( event : React . MouseEvent < HTMLDivElement > ) => {
97- forwardMouseEvent ( event , 'mousedown' ) ;
98- } ,
99- [ forwardMouseEvent ]
100- ) ;
101-
102- const handleMouseUp = useCallback (
103- ( event : React . MouseEvent < HTMLDivElement > ) => {
104- forwardMouseEvent ( event , 'mouseup' ) ;
105- } ,
106- [ forwardMouseEvent ]
107- ) ;
108-
10942 if ( ! metrics ) {
11043 return null ;
11144 }
@@ -166,11 +99,6 @@ function GridAccessibilityLayer({
16699 width,
167100 height,
168101 } }
169- onClick = { handleClick }
170- onDoubleClick = { handleDoubleClick }
171- onContextMenu = { handleContextMenu }
172- onMouseDown = { handleMouseDown }
173- onMouseUp = { handleMouseUp }
174102 >
175103 { text }
176104 </ div >
@@ -206,11 +134,6 @@ function GridAccessibilityLayer({
206134 width,
207135 height : columnHeaderHeight ,
208136 } }
209- onClick = { handleClick }
210- onDoubleClick = { handleDoubleClick }
211- onContextMenu = { handleContextMenu }
212- onMouseDown = { handleMouseDown }
213- onMouseUp = { handleMouseUp }
214137 >
215138 { text ?? '' }
216139 </ div >
@@ -244,11 +167,6 @@ function GridAccessibilityLayer({
244167 width : rowHeaderWidth ,
245168 height,
246169 } }
247- onClick = { handleClick }
248- onDoubleClick = { handleDoubleClick }
249- onContextMenu = { handleContextMenu }
250- onMouseDown = { handleMouseDown }
251- onMouseUp = { handleMouseUp }
252170 >
253171 { text }
254172 </ div >
0 commit comments