Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

feat: delay flashing skeleton on table

Brad Barbin00fe24f4ada2
diff --git a/apps/carbon/app/components/Table/Table.tsx b/apps/carbon/app/components/Table/Table.tsx
index e8917652c3..3d853ba54b 100644
--- a/apps/carbon/app/components/Table/Table.tsx
+++ b/apps/carbon/app/components/Table/Table.tsx
@@ -40,6 +40,7 @@ import {
import type { CSSProperties, ReactNode } from "react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { LuAlertTriangle, LuArrowDown, LuArrowUp } from "react-icons/lu";
+import { useSpinDelay } from "spin-delay";
import type {
EditableTableCellComponent,
Position,
@@ -545,6 +546,9 @@ const Table = <T extends object>({
const navigation = useNavigation();
const { hasFilters, clearFilters } = useFilters();
+ const isLoading = useSpinDelay(navigation.state === "loading", {
+ delay: 300,
+ });
return (
<VStack spacing={0} className="h-full">
@@ -574,7 +578,7 @@ const Table = <T extends object>({
>
<div className="flex max-w-full h-full">
{rows.length === 0 ? (
- navigation.state === "loading" ? (
+ isLoading ? (
<div className="flex h-full w-full items-start justify-center">
<TableBase className="w-full">
<Thead>
diff --git a/apps/carbon/package.json b/apps/carbon/package.json
index 0a5bc0fc2a..2563c266d2 100644
--- a/apps/carbon/package.json
+++ b/apps/carbon/package.json
@@ -69,6 +69,7 @@
"remix-flat-routes": "^0.6.5",
"remix-typedjson": "^0.4.1",
"resend": "^3.1.0",
+ "spin-delay": "2.0.1",
"tailwind-merge": "^2.2.1",
"tailwind-scrollbar": "^3.0.5",
"tailwind-scrollbar-hide": "^1.1.7",
diff --git a/package-lock.json b/package-lock.json
index 35bbcd9eed..2ae424fbc5 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -99,6 +99,7 @@
"remix-flat-routes": "^0.6.5",
"remix-typedjson": "^0.4.1",
"resend": "^3.1.0",
+ "spin-delay": "2.0.1",
"tailwind-merge": "^2.2.1",
"tailwind-scrollbar": "^3.0.5",
"tailwind-scrollbar-hide": "^1.1.7",
@@ -29325,6 +29326,14 @@
"resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.20.tgz",
"integrity": "sha512-jg25NiDV/1fLtSgEgyvVyDunvaNHbuwF9lfNV17gSmPFAlYzdfNBlLtLzXTevwkPj7DhGbmN9VnmJIgLnhvaBw=="
},
+ "node_modules/spin-delay": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/spin-delay/-/spin-delay-2.0.1.tgz",
+ "integrity": "sha512-ilggKXKqAMwk21PSYvxuF/KCnrsGFDrnO6mXa629mj8fvfo+dOQfubDViqsRjRX5U1jd3Xb8FTsV+m4Tg7YeUg==",
+ "peerDependencies": {
+ "react": ">=17.0.1"
+ }
+ },
"node_modules/split-string": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz",