fix: fixes organization table UI flickers and adds sticky search & filter + table header (#11711)

* fix: #11213, #11215

* Update packages/ui/components/data-table/DataTableToolbar.tsx

---------

Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
pull/11705/head^2
Siddharth Movaliya 2023-10-06 01:54:03 +05:30 committed by GitHub
parent bba52db02f
commit e7543c10a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 18 deletions

View File

@ -36,10 +36,10 @@ export function DataTableToolbar<TData>({
const isFiltered = table.getState().columnFilters.length > 0;
return (
<div className="flex items-center justify-end space-x-2">
<div className="bg-default sticky top-[3rem] z-10 flex items-center justify-end space-x-2 py-4 md:top-0">
{searchKey && (
<Input
className="max-w-64 mb-0 mr-auto"
className="max-w-64 mb-0 mr-auto rounded-md"
placeholder="Search"
value={(table.getColumn(searchKey)?.getFilterValue() as string) ?? ""}
onChange={(event) => table.getColumn(searchKey)?.setFilterValue(event.target.value)}

View File

@ -102,21 +102,9 @@ export function DataTable<TData, TValue>({
searchKey={searchKey}
tableCTA={tableCTA}
/>
<div
className="border-subtle rounded-md border"
ref={tableContainerRef}
onScroll={onScroll}
style={{
height: "calc(100vh - 30vh)",
overflow: "auto",
}}>
<div className="border-subtle border" ref={tableContainerRef} onScroll={onScroll}>
<Table>
<TableHeader
style={{
position: "sticky",
top: 0,
zIndex: 1,
}}>
<TableHeader>
{table.getHeaderGroups().map((headerGroup) => (
<TableRow key={headerGroup.id}>
{headerGroup.headers.map((header) => {

View File

@ -4,7 +4,7 @@ import { classNames } from "@calcom/lib";
const Table = React.forwardRef<HTMLTableElement, React.HTMLAttributes<HTMLTableElement>>(
({ className, ...props }, ref) => (
<div className="w-full overflow-auto">
<div className="w-full overflow-auto md:overflow-visible">
<table ref={ref} className={classNames("w-full caption-bottom text-sm", className)} {...props} />
</div>
)
@ -13,7 +13,11 @@ Table.displayName = "Table";
const TableHeader = React.forwardRef<HTMLTableSectionElement, React.HTMLAttributes<HTMLTableSectionElement>>(
({ className, ...props }, ref) => (
<thead ref={ref} className={classNames("[&_tr]:bg-subtle [&_tr]:border-b", className)} {...props} />
<thead
ref={ref}
className={classNames("[&_tr]:bg-subtle md:sticky md:top-[4.25rem] md:z-10 [&_tr]:border-b", className)}
{...props}
/>
)
);
TableHeader.displayName = "TableHeader";