Skip to content

Commit

Permalink
Merge pull request #1075 from Shelf-nu/fix-chromium-bug-while-scrolli…
Browse files Browse the repository at this point in the history
…ng-over-tables-with-row-hover-effects

fixing issue with scrolling cause by an ancient chromium bug
  • Loading branch information
DonKoko authored Jun 19, 2024
2 parents dda4b2f + cf75a63 commit 65fd37d
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 74 deletions.
13 changes: 4 additions & 9 deletions app/components/booking/booking-assets-column.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useMemo } from "react";

import React, { useMemo } from "react";
import type { Kit } from "@prisma/client";
import { AssetStatus, BookingStatus } from "@prisma/client";
import { useLoaderData } from "@remix-run/react";
Expand Down Expand Up @@ -136,12 +135,8 @@ export function BookingAssetsColumn() {
const kit = assets[0].kit as Kit;

return (
<>
<ListItem
item={kit}
key={kit.id}
className="bg-gray-50"
>
<React.Fragment key={kit.id}>
<ListItem item={kit} className="bg-gray-50">
<Td className="w-full">
<Button
to={`/kits/${kit.id}`}
Expand Down Expand Up @@ -173,7 +168,7 @@ export function BookingAssetsColumn() {
/>
</ListItem>
))}
</>
</React.Fragment>
);
})}
</tbody>
Expand Down
11 changes: 10 additions & 1 deletion app/components/list/list-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,22 @@ export const ListItem = ({
className?: string;
}) => (
<tr
key={item.id}
onClick={navigate ? () => navigate(item.id, item) : undefined}
className={tw(
"hover:bg-gray-50",
navigate ? "cursor-pointer" : "",
className
)}
/**
* Chromium based browsers have a bug since 2014 that is related to
* hover effects on table rows while scrolling.
* We add the following styles to fix the issue.
*/
style={{
transform: "translateZ(0)",
willChange: "transform",
backgroundAttachment: "initial",
}}
>
{children}
</tr>
Expand Down
104 changes: 40 additions & 64 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 65fd37d

Please sign in to comment.