🎥 Make videos programmatically with React
Fix Sequence opacity with premounting (#9308)
Jonny Burger2a8f151a4a9d
diff --git a/packages/core/src/Sequence.tsx b/packages/core/src/Sequence.tsxindex dfc37b6d5a..8d2aea2065 100644--- a/packages/core/src/Sequence.tsx+++ b/packages/core/src/Sequence.tsx@@ -612,7 +612,8 @@ const PremountedPostmountedSequenceRefForwardingFunction: React.ForwardRefRenderconst style = useMemo(() => {return {...passedStyle,- opacity: premountingActive || postmountingActive ? 0 : 1,+ opacity:+ premountingActive || postmountingActive ? 0 : passedStyle?.opacity,pointerEvents:premountingActive || postmountingActive? 'none'diff --git a/packages/core/src/test/sequence-premounting.test.tsx b/packages/core/src/test/sequence-premounting.test.tsxnew file mode 100644index 0000000000..3d53f4d78a--- /dev/null+++ b/packages/core/src/test/sequence-premounting.test.tsx@@ -0,0 +1,72 @@+import {afterEach, expect, test} from 'bun:test';+import {cleanup, render} from '@testing-library/react';+import type {ReactNode} from 'react';+import {Internals} from '../internals.js';+import {Sequence} from '../Sequence.js';+import {WrapSequenceContext} from './wrap-sequence-context.js';++afterEach(() => {+ cleanup();+});++const NonRenderingEnvironment = ({+ children,+}: {+ readonly children: ReactNode;+}) => {+ return (+ <Internals.RemotionEnvironmentContext+ value={{+ isRendering: false,+ isClientSideRendering: false,+ isPlayer: true,+ isStudio: false,+ isReadOnlyStudio: false,+ }}+ >+ {children}+ </Internals.RemotionEnvironmentContext>+ );+};++test('preserves the Sequence opacity while it is active', () => {+ const {container} = render(+ <WrapSequenceContext currentFrame={10}>+ <NonRenderingEnvironment>+ <Sequence+ from={10}+ durationInFrames={20}+ premountFor={10}+ style={{opacity: 0.5}}+ >+ Content+ </Sequence>+ </NonRenderingEnvironment>+ </WrapSequenceContext>,+ );++ expect(container.firstElementChild?.getAttribute('style')).toContain(+ 'opacity: 0.5',+ );+});++test('hides a Sequence while it is premounted', () => {+ const {container} = render(+ <WrapSequenceContext currentFrame={0}>+ <NonRenderingEnvironment>+ <Sequence+ from={10}+ durationInFrames={20}+ premountFor={10}+ style={{opacity: 0.5}}+ >+ Content+ </Sequence>+ </NonRenderingEnvironment>+ </WrapSequenceContext>,+ );++ expect(container.firstElementChild?.getAttribute('style')).toContain(+ 'opacity: 0',+ );+});