Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix: prevent concurrent custom field reorders

MonsPropreb0ed0ba57ee8
diff --git a/apps/web/src/components/project/custom-field-editor.tsx b/apps/web/src/components/project/custom-field-editor.tsx
index 6acafd4b7..29371f8df 100644
--- a/apps/web/src/components/project/custom-field-editor.tsx
+++ b/apps/web/src/components/project/custom-field-editor.tsx
@@ -97,6 +97,7 @@ export default function CustomFieldEditor({
const [pendingFields, setPendingFields] = useState<
CustomFieldDefinition[] | null
>(null);
+ const [isReordering, setIsReordering] = useState(false);
const dragPreviewRef = useRef<HTMLDivElement | null>(null);
@@ -167,6 +168,8 @@ export default function CustomFieldEditor({
e: React.DragEvent<HTMLDivElement>,
index: number,
) => {
+ if (isReordering) return;
+
if (!pendingFields && customFields) {
setPendingFields(customFields);
}
@@ -226,6 +229,8 @@ export default function CustomFieldEditor({
};
const handleDragEnd = async () => {
+ if (isReordering) return;
+
const finalFields = pendingFields ?? customFields;
setDraggedIndex(null);
@@ -241,6 +246,7 @@ export default function CustomFieldEditor({
if (pendingFields === null) {
return;
}
+ if (isReordering) return;
try {
const updates = finalFields.map((col, i) => ({
@@ -259,6 +265,8 @@ export default function CustomFieldEditor({
? error.message
: t("settings:customFields.reorderError", "Failed to reorder fields"),
);
+ } finally {
+ setIsReordering(false);
}
};
@@ -301,7 +309,7 @@ export default function CustomFieldEditor({
<div
key={field.id}
role="listitem"
- draggable
+ draggable={!isReordering}
onDragStart={(e) => handleDragStart(e, index)}
onDragOver={(e) => handleDragOver(e, index)}
onDragEnd={handleDragEnd}