Skip to content

Commit fe54b6c

Browse files
committed
fix(editor): fix annotation placeholder text and post-reload duration cap
Two bugs found during the 1.7.0 RC end-to-end pass: 1. New text annotations were created with the literal string "Enter text..." baked into their actual content, instead of starting empty with a real placeholder. The properties panel's textarea already had a proper `placeholder` attribute wired up, but since the field's *value* was never actually empty, the placeholder never showed and clicking in to type appended after the baked-in text instead of replacing it. Fixed by defaulting new text annotations' content to "" (both on creation and when switching an existing annotation's type to "text"), matching the pattern already used for "image"/"figure"/"blur" types. 2. After Save Project -> Load Project, the editor's scrubber/seek range was capped at the last timeline element's end time instead of the true recording duration. Root cause: `applyLoadedProject` sets `duration` to an inferred placeholder value (max of all region endMs) as a provisional guess before the real video metadata loads, expecting `VideoPlayback`'s `syncResolvedDuration` to correct it once the video element reports its real duration. But `syncResolvedDuration` skips calling `onDurationChange` whenever the resolved value matches `lastResolvedDurationRef` -- a memoization guard against redundant updates that has no way to know `applyLoadedProject` just set `duration` to something else. If the real duration happened to match what the ref already remembered from before the reload (the common case, since it's the same video file), the correction never fired and the inferred placeholder stuck. Fixed by exposing a `resetDurationResolution()` method on `VideoPlaybackRef` that clears the memoization guard, called from `applyLoadedProject` right when it sets the placeholder duration -- forcing the next metadata load to always re-sync regardless of what the guard last saw. Verified via computer-use against a real dev build: - New annotation's text field now shows a genuine empty value (real greyed placeholder, timeline label reads "Empty text"); typing replaces cleanly with no leftover baked-in text. - Loading a saved project with a trim region correctly shows the full original duration (1:10) and scrubs all the way to the end, instead of being capped at the last element's end time (previously 0:47). Full suite: 53 files / 423 tests pass. tsc --noEmit and biome check clean.
1 parent 44829d6 commit fe54b6c

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

‎src/components/video-editor/VideoEditor.tsx‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,11 @@ export default function VideoEditor() {
404404
} catch {
405405
// no-op
406406
}
407+
// This inferred duration is only a placeholder until the video element's real
408+
// metadata resolves (see VideoPlayback's syncResolvedDuration). Reset its memoized
409+
// last-resolved-duration guard so that resolution isn't skipped just because the
410+
// real duration happens to match a value already seen from before this load.
411+
videoPlaybackRef.current?.resetDurationResolution();
407412
setIsPlaying(false);
408413
setCurrentTime(0);
409414
setDuration(inferredDurationMs > 0 ? inferredDurationMs / 1000 : 0);
@@ -1477,7 +1482,7 @@ export default function VideoEditor() {
14771482
startMs: Math.round(span.start),
14781483
endMs: Math.round(span.end),
14791484
type: "text",
1480-
content: "Enter text...",
1485+
content: "",
14811486
position: { ...DEFAULT_ANNOTATION_POSITION },
14821487
size: { ...DEFAULT_ANNOTATION_SIZE },
14831488
style: { ...DEFAULT_ANNOTATION_STYLE },
@@ -1616,7 +1621,7 @@ export default function VideoEditor() {
16161621
if (region.id !== id) return region;
16171622
const updatedRegion = { ...region, type };
16181623
if (type === "text") {
1619-
updatedRegion.content = region.textContent || "Enter text...";
1624+
updatedRegion.content = region.textContent || "";
16201625
} else if (type === "image") {
16211626
updatedRegion.content = region.imageContent || "";
16221627
} else if (type === "figure") {

‎src/components/video-editor/VideoPlayback.tsx‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,14 @@ export interface VideoPlaybackRef {
165165
containerRef: React.RefObject<HTMLDivElement>;
166166
play: () => Promise<void>;
167167
pause: () => void;
168+
/**
169+
* Clears the memoized last-resolved-duration guard so the next metadata load
170+
* re-syncs `duration` even if the video's real (resolved) duration happens to
171+
* match a value already seen — needed when a caller (e.g. loading a saved
172+
* project) sets `duration` to something else in between, which the guard has
173+
* no other way to detect.
174+
*/
175+
resetDurationResolution: () => void;
168176
}
169177

170178
function getResolvedVideoDuration(video: HTMLVideoElement): number | null {
@@ -695,6 +703,9 @@ const VideoPlayback = forwardRef<VideoPlaybackRef, VideoPlaybackProps>(
695703
video.pause();
696704
supplementalAudioRef.current?.pause();
697705
},
706+
resetDurationResolution: () => {
707+
lastResolvedDurationRef.current = null;
708+
},
698709
}));
699710

700711
const updateFocusFromClientPoint = (clientX: number, clientY: number) => {

0 commit comments

Comments
 (0)