@@ -79,20 +79,45 @@ export const TableRow = forwardRef<HTMLTableRowElement, TableRowProps>(
7979 ( { className, disabled, isSelected, children, to, onClick } , ref ) => {
8080 const navigate = useNavigate ( ) ;
8181
82- const handleInteraction = ( event : React . KeyboardEvent | React . MouseEvent ) => {
83- if ( ( event . target as HTMLElement ) . closest ( 'button, a, [role="button"]' ) ) {
82+ const handleNavigation = ( event : React . KeyboardEvent | React . MouseEvent ) => {
83+ // Don't trigger navigation if clicking on interactive elements
84+ if ( ( event . target as HTMLElement ) . closest ( 'button, a, [role="button"], [role="menu"]' ) ) {
8485 return ;
8586 }
8687
87- const firstCellWithTo = React . Children . toArray ( children ) . find ( ( child ) => {
88- if ( React . isValidElement ( child ) && child . type === TableCell ) {
89- return child . props . to ;
88+ // For mouse events
89+ if ( "button" in event ) {
90+ // Handle middle mouse button click
91+ if ( event . button === 1 ) {
92+ return ; // Let default behavior handle middle click
9093 }
91- return false ;
92- } ) as React . ReactElement | undefined ;
9394
94- if ( firstCellWithTo ?. props . to ) {
95- navigate ( firstCellWithTo . props . to ) ;
95+ // Handle CMD/CTRL + Click
96+ if ( event . metaKey || event . ctrlKey ) {
97+ if ( to ) {
98+ window . open ( to , "_blank" ) ;
99+ }
100+ return ;
101+ }
102+ }
103+
104+ // For keyboard events
105+ if ( "key" in event ) {
106+ if ( event . key === "Enter" ) {
107+ if ( event . metaKey || event . ctrlKey ) {
108+ if ( to ) {
109+ window . open ( to , "_blank" ) ;
110+ }
111+ return ;
112+ }
113+ } else {
114+ return ; // Only handle Enter key for keyboard events
115+ }
116+ }
117+
118+ // Default navigation behavior
119+ if ( to ) {
120+ navigate ( to ) ;
96121 } else if ( onClick ) {
97122 onClick ( event ) ;
98123 }
@@ -102,22 +127,24 @@ export const TableRow = forwardRef<HTMLTableRowElement, TableRowProps>(
102127 if ( event . key === "Enter" ) {
103128 event . preventDefault ( ) ;
104129 event . stopPropagation ( ) ;
105- handleInteraction ( event ) ;
130+ handleNavigation ( event ) ;
106131 }
107132 } ;
108133
109134 return (
110135 < tr
111136 ref = { ref }
137+ role = "link"
112138 tabIndex = { disabled ? - 1 : 0 }
113- onClick = { handleInteraction }
139+ onClick = { handleNavigation }
114140 onKeyDown = { handleKeyDown }
115141 className = { cn (
116142 "group/table-row relative w-full cursor-pointer outline-none after:absolute after:bottom-0 after:left-3 after:right-0 after:h-px after:bg-grid-dimmed focus-visible:bg-background-bright" ,
117- disabled && "opacity-50" ,
143+ disabled && "cursor-not-allowed opacity-50" ,
118144 isSelected && isSelectedStyle ,
119145 className
120146 ) }
147+ aria-disabled = { disabled }
121148 >
122149 { children }
123150 </ tr >
@@ -236,6 +263,7 @@ export const TableCell = forwardRef<HTMLTableCellElement, TableCellProps>(
236263 isSticky && stickyStyles ,
237264 isSelected && isSelectedStyle ,
238265 ! isSelected && rowHoverStyles [ rowHoverStyle ] ,
266+ "child:pointer-events-none [&>[role=button]]:pointer-events-auto [&>[role=menu]]:pointer-events-auto [&>a]:pointer-events-auto [&>button]:pointer-events-auto" ,
239267 className
240268 ) }
241269 colSpan = { colSpan }
0 commit comments