@@ -79,45 +79,20 @@ export const TableRow = forwardRef<HTMLTableRowElement, TableRowProps>(
7979 ( { className, disabled, isSelected, children, to, onClick } , ref ) => {
8080 const navigate = useNavigate ( ) ;
8181
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"]' ) ) {
82+ const handleInteraction = ( event : React . KeyboardEvent | React . MouseEvent ) => {
83+ if ( ( event . target as HTMLElement ) . closest ( 'button, a, [role="button"]' ) ) {
8584 return ;
8685 }
8786
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
87+ const firstCellWithTo = React . Children . toArray ( children ) . find ( ( child ) => {
88+ if ( React . isValidElement ( child ) && child . type === TableCell ) {
89+ return child . props . to ;
9390 }
91+ return false ;
92+ } ) as React . ReactElement | undefined ;
9493
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 ) ;
94+ if ( firstCellWithTo ?. props . to ) {
95+ navigate ( firstCellWithTo . props . to ) ;
12196 } else if ( onClick ) {
12297 onClick ( event ) ;
12398 }
@@ -127,24 +102,22 @@ export const TableRow = forwardRef<HTMLTableRowElement, TableRowProps>(
127102 if ( event . key === "Enter" ) {
128103 event . preventDefault ( ) ;
129104 event . stopPropagation ( ) ;
130- handleNavigation ( event ) ;
105+ handleInteraction ( event ) ;
131106 }
132107 } ;
133108
134109 return (
135110 < tr
136111 ref = { ref }
137- role = "link"
138112 tabIndex = { disabled ? - 1 : 0 }
139- onClick = { handleNavigation }
113+ onClick = { handleInteraction }
140114 onKeyDown = { handleKeyDown }
141115 className = { cn (
142116 "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" ,
143- disabled && "cursor-not-allowed opacity-50" ,
117+ disabled && "opacity-50" ,
144118 isSelected && isSelectedStyle ,
145119 className
146120 ) }
147- aria-disabled = { disabled }
148121 >
149122 { children }
150123 </ tr >
@@ -263,7 +236,6 @@ export const TableCell = forwardRef<HTMLTableCellElement, TableCellProps>(
263236 isSticky && stickyStyles ,
264237 isSelected && isSelectedStyle ,
265238 ! 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" ,
267239 className
268240 ) }
269241 colSpan = { colSpan }
0 commit comments