From 2ef6d5081bdfda0e914449ea6d4d9f9a212a438b Mon Sep 17 00:00:00 2001
From: Amita Rajput
Date: Tue, 19 May 2026 23:21:58 +0530
Subject: [PATCH] fix: prevent zero-length clip in TrimControl (#14)
---
src/components/TrimControl.tsx | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/components/TrimControl.tsx b/src/components/TrimControl.tsx
index 5df0ab46..7521f12f 100644
--- a/src/components/TrimControl.tsx
+++ b/src/components/TrimControl.tsx
@@ -2,6 +2,8 @@
import { EditRecipe } from "@/lib/types";
+const MIN_CLIP_DURATION = 0.1;
+
interface Props {
recipe: EditRecipe;
onChange: (patch: Partial) => void;
@@ -13,14 +15,14 @@ export default function TrimControl({ recipe, onChange, duration }: Props) {
const n = parseFloat(val);
if (isNaN(n) || n < 0) return;
if (duration > 0 && n >= duration) return;
- if (recipe.trimEnd !== null && n >= recipe.trimEnd) return;
+ if (recipe.trimEnd !== null && n >= recipe.trimEnd - MIN_CLIP_DURATION) return;
onChange({ trimStart: n });
};
const handleEnd = (val: string) => {
if (val === "") { onChange({ trimEnd: null }); return; }
const n = parseFloat(val);
- if (isNaN(n) || n <= 0 || n <= recipe.trimStart) return;
+ if (isNaN(n) || n <= 0 || n <= recipe.trimStart + MIN_CLIP_DURATION) return;
if (duration > 0 && n > duration) return;
onChange({ trimEnd: n });
};
@@ -67,6 +69,12 @@ export default function TrimControl({ recipe, onChange, duration }: Props) {
Duration: {duration.toFixed(1)}s
)}
+ {recipe.trimEnd !== null &&
+ recipe.trimEnd - recipe.trimStart < MIN_CLIP_DURATION && (
+
+ Clip must be at least 0.1 seconds long.
+
+ )}
);
}