Skip to content

🎥 Make videos programmatically with React

Require nullable composition ID in wrapping requests

Jonny Burgera42ad0ea05cc
diff --git a/packages/browser-studio/src/browser-studio-operations.ts b/packages/browser-studio/src/browser-studio-operations.ts
index 2afd8f4bc7..553b4ce835 100644
--- a/packages/browser-studio/src/browser-studio-operations.ts
+++ b/packages/browser-studio/src/browser-studio-operations.ts
@@ -1470,13 +1470,14 @@ export const createBrowserStudioOperations = ({
: {},
}),
});
- const insertedNodePath = result.nodePathRemappings.find(
- (remapping) => remapping.oldNodePath === null,
- )?.newNodePath;
+ const insertedNodePath =
+ result.nodePathRemappings.find(
+ (remapping) => remapping.oldNodePath === null,
+ )?.newNodePath ?? null;
const nodePathMutation = controller.applyMutation({
undoRedoNavigation: null,
timelineSelection:
- compositionId && insertedNodePath
+ compositionId !== null && insertedNodePath !== null
? {
compositionId,
absolutePath: filePath,
diff --git a/packages/browser-studio/src/test/browser-studio-operations.test.ts b/packages/browser-studio/src/test/browser-studio-operations.test.ts
index 1b60212911..6e9482e905 100644
--- a/packages/browser-studio/src/test/browser-studio-operations.test.ts
+++ b/packages/browser-studio/src/test/browser-studio-operations.test.ts
@@ -962,6 +962,7 @@ export const Component = () => <AbsoluteFill><div /></AbsoluteFill>;`;
const result = await operations.wrapNode({
fileName,
+ compositionId: null,
nodePath,
wrapper: 'Sequence',
width: null,
diff --git a/packages/studio-server/src/preview-server/routes/wrap-node.ts b/packages/studio-server/src/preview-server/routes/wrap-node.ts
index 66f382f582..d7e3dc5c71 100644
--- a/packages/studio-server/src/preview-server/routes/wrap-node.ts
+++ b/packages/studio-server/src/preview-server/routes/wrap-node.ts
@@ -85,12 +85,12 @@ export const wrapNodeHandler: ApiHandler<WrapNodeRequest, WrapNodeResponse> = ({
newJsxName,
}),
);
- const insertedNodePath = remappings.find(
- (remapping) => remapping.oldNodePath === null,
- )?.newNodePath;
+ const insertedNodePath =
+ remappings.find((remapping) => remapping.oldNodePath === null)
+ ?.newNodePath ?? null;
const nodePathMutation = broadcastSequenceNodePathMutation(
[{absolutePath, remappings}],
- compositionId && insertedNodePath
+ compositionId !== null && insertedNodePath !== null
? {compositionId, absolutePath, nodePath: insertedNodePath}
: null,
);
diff --git a/packages/studio-server/src/test/wrap-node.test.ts b/packages/studio-server/src/test/wrap-node.test.ts
index e468c47805..9e49e6d852 100644
--- a/packages/studio-server/src/test/wrap-node.test.ts
+++ b/packages/studio-server/src/test/wrap-node.test.ts
@@ -44,6 +44,7 @@ export const Comp = () => {
const result = await wrapNodeHandler({
input: {
fileName: entryPoint,
+ compositionId: null,
nodePath: lineContainingToNodePath(input, '<AbsoluteFill'),
wrapper: 'HtmlInCanvas',
width: 2560,
diff --git a/packages/studio-shared/src/api-requests.ts b/packages/studio-shared/src/api-requests.ts
index 506f73a85c..c2e8e5040b 100644
--- a/packages/studio-shared/src/api-requests.ts
+++ b/packages/studio-shared/src/api-requests.ts
@@ -963,7 +963,7 @@ export type NodeWrapper =
export type WrapNodeRequest = {
fileName: string;
- compositionId?: string | null;
+ compositionId: string | null;
nodePath: SequenceNodePath;
wrapper: NodeWrapper | null;
width: number | null;