Skip to content

Commit 2d015d3

Browse files
authored
Merge pull request #497 from performant-software/feature/cdp201_table_scroll
CDP #201 - Table scroll
2 parents 603feb1 + 959d574 commit 2d015d3

File tree

1 file changed

+46
-48
lines changed

1 file changed

+46
-48
lines changed

packages/core-data/src/components/SearchResultsTable.js

Lines changed: 46 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -78,59 +78,57 @@ const SearchResultsTable = (props: Props) => {
7878
};
7979

8080
return (
81-
<div className='rounded-md inline-block border border-neutral-200 w-full h-full min-h-full flex flex-col'>
82-
<div className='overflow-auto'>
83-
<table
84-
className='divide-y divide-neutral-200 w-full max-h-full overflow-auto border-b border-neutral-200 grow-0'
85-
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
86-
tabIndex={0}
87-
>
88-
<thead className='bg-neutral-100 sticky top-0'>
89-
<tr className='divide-x divide-neutral-200'>
81+
<div
82+
className='rounded-md border border-neutral-200 w-full h-full min-h-full flex flex-col overflow-auto'
83+
>
84+
<table
85+
className='divide-y divide-neutral-200 w-full max-h-full overflow-auto border-b border-neutral-200 grow-0'
86+
>
87+
<thead className='bg-neutral-100 sticky top-0'>
88+
<tr className='divide-x divide-neutral-200'>
89+
{props.columns.map((col) => (
90+
<th
91+
className='px-4 py-3 text-left text-sm font-bold text-gray-800 max-h-10'
92+
key={col.name}
93+
>
94+
{col.label}
95+
</th>
96+
))}
97+
</tr>
98+
</thead>
99+
<tbody className='divide-y divide-neutral-200 border-b border-neutral-200'>
100+
{hitsToShow.map((hit, idx) => (
101+
<tr
102+
className={clsx(
103+
'divide-x divide-neutral-200',
104+
{ 'hover:bg-primary/20 cursor-pointer': props.onRowClick },
105+
{ 'bg-primary/20': props.isHighlight && props.isHighlight(hit) }
106+
)}
107+
onClick={props.onRowClick
108+
? () => props.onRowClick(hit)
109+
: undefined}
110+
onPointerEnter={props.onRowPointerEnter
111+
? () => props.onRowPointerEnter(hit)
112+
: undefined}
113+
onPointerLeave={props.onRowPointerLeave
114+
? () => props.onRowPointerLeave(hit)
115+
: undefined}
116+
key={idx}
117+
>
90118
{props.columns.map((col) => (
91-
<th
92-
className='px-4 py-3 text-left text-sm font-bold text-gray-800 max-h-10'
119+
<td
120+
className='px-4 py-3 text-sm text-gray-800 text-sm max-h-10'
93121
key={col.name}
94122
>
95-
{col.label}
96-
</th>
123+
{col.render
124+
? col.render(hit)
125+
: hit[col.name]}
126+
</td>
97127
))}
98128
</tr>
99-
</thead>
100-
<tbody className='divide-y divide-neutral-200 border-b border-neutral-200'>
101-
{hitsToShow.map((hit, idx) => (
102-
<tr
103-
className={clsx(
104-
'divide-x divide-neutral-200',
105-
{ 'hover:bg-primary/20 cursor-pointer': props.onRowClick },
106-
{ 'bg-primary/20': props.isHighlight && props.isHighlight(hit) }
107-
)}
108-
onClick={props.onRowClick
109-
? () => props.onRowClick(hit)
110-
: undefined}
111-
onPointerEnter={props.onRowPointerEnter
112-
? () => props.onRowPointerEnter(hit)
113-
: undefined}
114-
onPointerLeave={props.onRowPointerLeave
115-
? () => props.onRowPointerLeave(hit)
116-
: undefined}
117-
key={idx}
118-
>
119-
{props.columns.map((col) => (
120-
<td
121-
className='px-4 py-3 text-sm text-gray-800 text-sm max-h-10'
122-
key={col.name}
123-
>
124-
{col.render
125-
? col.render(hit)
126-
: hit[col.name]}
127-
</td>
128-
))}
129-
</tr>
130-
))}
131-
</tbody>
132-
</table>
133-
</div>
129+
))}
130+
</tbody>
131+
</table>
134132
{/* this empty div keeps the Pagination bar at the bottom, even
135133
when there aren't enough results to fill the table */}
136134
<div className='grow' />

0 commit comments

Comments
 (0)