Skip to content

Commit 9d9a728

Browse files
authored
Merge pull request #26 from datopian/1464-fix-table-preview-issues
[BUG FIX] Frontend table preview
2 parents b3d572c + 6bb6332 commit 9d9a728

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

components/responsiveGrid/Table.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
import { useEffect, useRef } from "react";
12
import { useResourceData } from "./DataProvider";
23
import TableColumnValue from "./TableColValue";
34
import TableHead from "./TableHead";
45

56
export 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"

components/responsiveGrid/TableColValue.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff 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
)}

0 commit comments

Comments
 (0)