Skip to content

🎥 Make videos programmatically with React

@remotion/studio: Import captions without confirmation

Igor Samokhovetsfcd9830e2658
diff --git a/packages/example/e2e/captions-inspector.test.mts b/packages/example/e2e/captions-inspector.test.mts
index 2a87f3b7d9..48156f2638 100644
--- a/packages/example/e2e/captions-inspector.test.mts
+++ b/packages/example/e2e/captions-inspector.test.mts
@@ -156,13 +156,6 @@ test.describe('captions inspector', () => {
]),
),
});
- await expect(
- page.getByText('Replace captions?', {exact: true}),
- ).toBeVisible();
- expect(fs.readFileSync(elementCaptionsFile, 'utf-8')).toBe(
- sourceBeforeFailedImport,
- );
- await page.getByRole('button', {name: 'Replace captions'}).click();
await expect(defaultCaption).toHaveValue('Imported');
await expect
.poll(() => fs.readFileSync(elementCaptionsFile, 'utf-8'))
diff --git a/packages/studio/src/components/CaptionInspector.tsx b/packages/studio/src/components/CaptionInspector.tsx
index d3b83f9657..162ca36fca 100644
--- a/packages/studio/src/components/CaptionInspector.tsx
+++ b/packages/studio/src/components/CaptionInspector.tsx
@@ -4,7 +4,6 @@ import {CURRENT_COLOR, LIGHT_TEXT} from '../helpers/colors';
import {UploadIcon} from '../icons/upload';
import {Button} from './Button';
import {CaptionTextEditor} from './CaptionTextEditor';
-import {useConfirmationDialog} from './ConfirmationDialog';
import {CollapsibleInspectorSectionHeader} from './InspectorPanel/CollapsibleInspectorSectionHeader';
import {InspectorSectionHeader} from './InspectorPanel/common';
import {sectionHeaderEnd} from './InspectorPanel/styles';
@@ -47,7 +46,6 @@ export const CaptionInspector: React.FC<{
}) => {
const fileInput = useRef<HTMLInputElement>(null);
const [isImporting, setIsImporting] = useState(false);
- const confirm = useConfirmationDialog();
const importCaptions = useCallback(
async (event: React.ChangeEvent<HTMLInputElement>) => {
@@ -59,23 +57,12 @@ export const CaptionInspector: React.FC<{
setIsImporting(true);
try {
- const importedCaptions = parseCaptionFile({
- fileName: file.name,
- contents: await file.text(),
- });
- if (
- captions.length > 0 &&
- !(await confirm({
- title: 'Replace captions?',
- message: `This will replace ${captions.length} existing ${captions.length === 1 ? 'caption' : 'captions'} with ${importedCaptions.length} imported ${importedCaptions.length === 1 ? 'caption' : 'captions'}. You can undo this action.`,
- confirmLabel: 'Replace captions',
- cancelLabel: 'Cancel',
- }))
- ) {
- return;
- }
-
- onReplaceCaptions(importedCaptions);
+ onReplaceCaptions(
+ parseCaptionFile({
+ fileName: file.name,
+ contents: await file.text(),
+ }),
+ );
} catch (error) {
showNotification(
`Could not import ${file.name}: ${error instanceof Error ? error.message : String(error)}`,
@@ -85,7 +72,7 @@ export const CaptionInspector: React.FC<{
setIsImporting(false);
}
},
- [captions.length, confirm, onReplaceCaptions],
+ [onReplaceCaptions],
);
return (