File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed
components/responsiveGrid Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change 1+ import { useEffect , useRef } from "react" ;
12import { useResourceData } from "./DataProvider" ;
23import TableColumnValue from "./TableColValue" ;
34import TableHead from "./TableHead" ;
45
56export default function TableData ( ) {
6- const { paginatedData, columns } = useResourceData ( ) ;
7+ const { paginatedData, columns, data } = useResourceData ( ) ;
8+ const scrollRef = useRef < HTMLDivElement > ( null ) ;
9+ useEffect ( ( ) => {
10+ if ( scrollRef . current ) {
11+ setTimeout ( ( ) => {
12+ if ( scrollRef . current ) {
13+ scrollRef . current . scrollLeft = 0 ;
14+ } } , 100 ) ;
15+ }
16+ } , [ data ] ) ;
717 return (
8- < div className = "overflow-auto max-h-[750px] relative border-y min-h-[500px] w-full" >
18+ < div ref = { scrollRef } className = "overflow-auto max-h-[750px] relative border-y min-h-[500px] w-full" >
919 { /* Table */ }
1020 < table
1121 className = "min-w-full table-auto border-collapse border-0 static"
Original file line number Diff line number Diff line change @@ -4,16 +4,18 @@ export default function TableColumnValue({ column, value }) {
44 const { visibleColumns, pinnedColumns } = useResourceData ( ) ;
55 const isVisible = visibleColumns . includes ( column ) ;
66 const isPinned = pinnedColumns . includes ( column ) ;
7+ const _value = typeof value === "boolean" ? value . toString ( ) : value ;
8+
79 return (
810 < td
9- className = { ` px-3 py-4 text-sm text-gray-500 ${
11+ className = { `px-3 py-4 text-sm text-gray-500 ${
1012 ! isVisible ? "hidden" : ""
1113 } ${ isPinned ? "sticky left-[-1px] bg-accent-50 z-10 font-medium" : "" } `}
1214 role = "gridcell"
1315 tabIndex = { 0 }
14- aria-label = { value }
16+ aria-label = { _value }
1517 >
16- < span className = " block max-w-[400px] w-[max-content] " > { value } </ span >
18+ < span className = "block max-w-[400px] w-[max-content]" > { _value } </ span >
1719 { isPinned && (
1820 < span className = "absolute right-[-1px] h-full w-[1px] bg-gray-100 top-0" > </ span >
1921 ) }
You can’t perform that action at this time.
0 commit comments