Skip to content

🎥 Make videos programmatically with React

save when blurring textarea

Jonny Burgerc70368c00283
diff --git a/packages/example/e2e/studio.test.mts b/packages/example/e2e/studio.test.mts
index 805866d042..8fdfb98e33 100644
--- a/packages/example/e2e/studio.test.mts
+++ b/packages/example/e2e/studio.test.mts
@@ -174,4 +174,60 @@ test.describe('Remotion Studio', () => {
});
expect(updateLogs).toHaveLength(1);
});
+
+ test('should edit props via JSON editor and save on blur', async ({
+ page,
+ }) => {
+ // Expand the right sidebar
+ await page.goto(STUDIO_URL);
+ await page.evaluate(() => {
+ window.localStorage.setItem(
+ 'remotion.sidebarRightCollapsing',
+ 'expanded',
+ );
+ });
+ await page.reload();
+
+ await navigateToSchemaTest(page);
+
+ // Switch to JSON tab
+ const jsonTab = page.getByRole('button', {name: 'JSON', exact: true});
+ await expect(jsonTab).toBeVisible({timeout: 10_000});
+ await jsonTab.click();
+
+ // Wait for the JSON textarea to appear
+ const textarea = page.locator('textarea');
+ await expect(textarea).toBeVisible({timeout: 10_000});
+
+ // Read the current JSON, parse it, change the title, and set it back
+ const currentJson = await textarea.inputValue();
+ const parsed = JSON.parse(currentJson);
+ const newTitle = 'json-editor-e2e-test';
+
+ // Verify the new value is not already in the source file
+ const beforeContent = fs.readFileSync(rootFile, 'utf-8');
+ expect(beforeContent).not.toContain(newTitle);
+
+ parsed.title = newTitle;
+ const newJson = JSON.stringify(parsed, null, 2);
+
+ await textarea.fill(newJson);
+
+ // Blur to trigger save
+ await textarea.blur();
+
+ // Wait for the file to be updated
+ await expect
+ .poll(
+ () => {
+ const content = fs.readFileSync(rootFile, 'utf-8');
+ return content.includes(newTitle);
+ },
+ {
+ message: `Expected Root.tsx to contain "${newTitle}" after JSON editor edit`,
+ timeout: 10_000,
+ },
+ )
+ .toBe(true);
+ });
});
diff --git a/packages/studio/src/components/RenderModal/RenderModalJSONPropsEditor.tsx b/packages/studio/src/components/RenderModal/RenderModalJSONPropsEditor.tsx
index e1d7c8d84d..ef83177141 100644
--- a/packages/studio/src/components/RenderModal/RenderModalJSONPropsEditor.tsx
+++ b/packages/studio/src/components/RenderModal/RenderModalJSONPropsEditor.tsx
@@ -141,6 +141,7 @@ export const RenderModalJSONPropsEditor: React.FC<{
<div style={scrollable}>
<RemTextarea
onChange={onChange}
+ onBlur={onQuickSave}
value={localValue.str}
status={localValue.validJSON ? 'ok' : 'error'}
style={textAreaStyle}