Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(editor): address CodeRabbit review on Full Camera

Etienne Lescot501de43bbb14
diff --git a/src/components/video-editor/timeline/TimelineEditor.tsx b/src/components/video-editor/timeline/TimelineEditor.tsx
index cba7950e2..b6e323a31 100644
--- a/src/components/video-editor/timeline/TimelineEditor.tsx
+++ b/src/components/video-editor/timeline/TimelineEditor.tsx
@@ -1083,10 +1083,14 @@ export default function TimelineEditor({
const cameraFullscreenRegionsRef = useRef(cameraFullscreenRegions);
const trimRegionsRef = useRef(trimRegions);
const speedRegionsRef = useRef(speedRegions);
- zoomRegionsRef.current = zoomRegions;
- cameraFullscreenRegionsRef.current = cameraFullscreenRegions;
- trimRegionsRef.current = trimRegions;
- speedRegionsRef.current = speedRegions;
+ // Sync refs in an effect (not during render) so render stays pure; defined before
+ // the normalization effect below so that effect reads the freshest region values.
+ useEffect(() => {
+ zoomRegionsRef.current = zoomRegions;
+ cameraFullscreenRegionsRef.current = cameraFullscreenRegions;
+ trimRegionsRef.current = trimRegions;
+ speedRegionsRef.current = speedRegions;
+ }, [zoomRegions, cameraFullscreenRegions, trimRegions, speedRegions]);
useEffect(() => {
if (totalMs === 0 || safeMinDurationMs <= 0) {
diff --git a/src/i18n/locales/fr/shortcuts.json b/src/i18n/locales/fr/shortcuts.json
index 4165f1382..fc6cd0c93 100644
--- a/src/i18n/locales/fr/shortcuts.json
+++ b/src/i18n/locales/fr/shortcuts.json
@@ -22,7 +22,7 @@
"addAnnotation": "Ajouter une annotation",
"addBlur": "Ajouter un flou",
"addKeyframe": "Ajouter une image-clé",
- "addCameraFullscreen": "Ajouter Caméra plein écran",
+ "addCameraFullscreen": "Ajouter une caméra en plein écran",
"deleteSelected": "Supprimer la sélection",
"playPause": "Lecture / Pause",
"copySelected": "Copier la sélection",
diff --git a/src/lib/compositeLayout.test.ts b/src/lib/compositeLayout.test.ts
index abe06c324..2cdef3245 100644
--- a/src/lib/compositeLayout.test.ts
+++ b/src/lib/compositeLayout.test.ts
@@ -275,7 +275,7 @@ describe("computeCameraFullscreenTargetRect", () => {
const margin = Math.round(
Math.min(canvasSize.width, canvasSize.height) * CAMERA_FULLSCREEN_MARGIN_FRACTION,
);
- // Square aspect source so width is the constrained dimension in a landscape canvas.
+ // Square aspect source so height is the constrained dimension in a landscape canvas.
const rect = computeCameraFullscreenTargetRect(canvasSize, { width: 1080, height: 1080 });
expect(rect.height).toBeCloseTo(canvasSize.height - margin * 2, 0);
@@ -290,7 +290,7 @@ describe("computeCameraFullscreenTargetRect", () => {
expect(rect.width / rect.height).toBeCloseTo(source.width / source.height, 3);
});
- it("fits a portrait source by constraining width, centering vertically and horizontally", () => {
+ it("fits a portrait source by constraining height, centering vertically and horizontally", () => {
const canvasSize = { width: 1920, height: 1080 };
const source = { width: 9, height: 16 }; // portrait webcam frame
const rect = computeCameraFullscreenTargetRect(canvasSize, source);
@@ -302,7 +302,7 @@ describe("computeCameraFullscreenTargetRect", () => {
expect(rect.x).toBeCloseTo(canvasSize.width - rect.x - rect.width, 0);
});
- it("fits a landscape source by constraining height when it would overflow", () => {
+ it("fits a landscape source by constraining width when it would overflow", () => {
const canvasSize = { width: 1080, height: 1920 }; // portrait canvas
const source = { width: 16, height: 9 }; // landscape webcam frame
const rect = computeCameraFullscreenTargetRect(canvasSize, source);