🎥 Make videos programmatically with React
`@remotion/studio`: Fix computed property controls (#10536)
Jonny Burgeref06db3fabe4
diff --git a/packages/studio/src/components/Timeline/TimelineEffectPropItem.tsx b/packages/studio/src/components/Timeline/TimelineEffectPropItem.tsxindex 798cf8ea83..f99cd99d43 100644--- a/packages/studio/src/components/Timeline/TimelineEffectPropItem.tsx+++ b/packages/studio/src/components/Timeline/TimelineEffectPropItem.tsx@@ -77,10 +77,9 @@ const isResettableStatus = ({const TimelineComputedEffectPropValue: React.FC<{readonly field: EffectSchemaFieldInfo;- readonly nodePath: SequencePropsSubscriptionKey;readonly propStatus: CanUpdateSequencePropStatusFalse;readonly runtimeValueStore: RuntimeValueStore | null;-}> = ({field, nodePath, propStatus, runtimeValueStore}) => {+}> = ({field, propStatus, runtimeValueStore}) => {const runtimeValue = useRuntimeStoreValue(runtimeValueStore, field.key);return (@@ -88,7 +87,6 @@ const TimelineComputedEffectPropValue: React.FC<{propStatus={propStatus}field={field}runtimeValue={runtimeValue}- scaleLockNodePath={nodePath}fixHref={TIMELINE_COMPUTED_EFFECT_FIX_LINK}/>);@@ -292,7 +290,6 @@ export const TimelineEffectPropValue: React.FC<{propStatus={{status: 'computed'}}field={field}runtimeValueStore={runtimeValueStore}- nodePath={nodePath}/>);}@@ -353,7 +350,6 @@ export const TimelineEffectPropValue: React.FC<{propStatus={propStatus}field={field}runtimeValueStore={runtimeValueStore}- nodePath={nodePath}/>);}diff --git a/packages/studio/src/components/Timeline/TimelineKeyframeControls.tsx b/packages/studio/src/components/Timeline/TimelineKeyframeControls.tsxindex 65698b83ce..27ec7a923c 100644--- a/packages/studio/src/components/Timeline/TimelineKeyframeControls.tsx+++ b/packages/studio/src/components/Timeline/TimelineKeyframeControls.tsx@@ -482,6 +482,10 @@ export const shouldShowTimelineKeyframeNavigation = ({readonly propStatus: CanUpdateSequencePropStatus;readonly selected: boolean;}) => {+ if (propStatus.status === 'computed') {+ return false;+ }+if (selected) {return true;}diff --git a/packages/studio/src/components/Timeline/TimelineSchemaField.tsx b/packages/studio/src/components/Timeline/TimelineSchemaField.tsxindex 2da5918d63..1819a3d50a 100644--- a/packages/studio/src/components/Timeline/TimelineSchemaField.tsx+++ b/packages/studio/src/components/Timeline/TimelineSchemaField.tsx@@ -10,6 +10,7 @@ import type {TimelineFieldOnDragValueChange,TimelineFieldOnSave,} from '../../helpers/timeline-layout';+import {formatTimelineFieldValueForDisplay} from './timeline-field-display-utils';import {TimelineArrayField} from './TimelineArrayField';import {isTimelinePrimitiveFieldInfo,@@ -52,7 +53,7 @@ const fixLinkBase: React.CSSProperties = {};export const UnsupportedStatus: React.FC<{- readonly label: React.ReactNode;+ readonly label: string;readonly fixHref?: string;readonly formattedValue: boolean;}> = ({label, fixHref, formattedValue}) => {@@ -86,10 +87,7 @@ export const UnsupportedStatus: React.FC<{onPointerEnter={() => setHovered(true)}onPointerLeave={() => setHovered(false)}>- <span- style={formattedValue ? computedValue : unsupportedLabel}- inert={formattedValue}- >+ <span style={formattedValue ? computedValue : unsupportedLabel}>{label}</span>{fixHref ? (@@ -117,27 +115,15 @@ export const TimelineNonEditableStatus: React.FC<{readonly propStatus: CanUpdateSequencePropStatusFalse;readonly field: SchemaFieldInfo;readonly runtimeValue: unknown;- readonly scaleLockNodePath: SequencePropsSubscriptionKey | null;readonly fixHref: string;-}> = ({propStatus, field, runtimeValue, scaleLockNodePath, fixHref}) => {+}> = ({propStatus, field, runtimeValue, fixHref}) => {if (propStatus.status === 'computed') {return (<UnsupportedStatus- label={- <TimelineFieldValue- field={field}- onSave={() => Promise.resolve()}- onDragValueChange={() => undefined}- onDragEnd={() => undefined}- propStatus={{- status: 'static',- codeValue: runtimeValue,- keyframeDisplayOffsetAdjustment: null,- }}- effectiveValue={runtimeValue}- scaleLockNodePath={scaleLockNodePath}- />- }+ label={formatTimelineFieldValueForDisplay({+ fieldSchema: field.fieldSchema,+ value: runtimeValue,+ })}fixHref={fixHref}formattedValue/>diff --git a/packages/studio/src/components/Timeline/TimelineSequencePropItem.tsx b/packages/studio/src/components/Timeline/TimelineSequencePropItem.tsxindex 0919fd41bb..260d4d5a0c 100644--- a/packages/studio/src/components/Timeline/TimelineSequencePropItem.tsx+++ b/packages/studio/src/components/Timeline/TimelineSequencePropItem.tsx@@ -605,7 +605,6 @@ export const TimelineSequencePropItem: React.FC<{propStatus={propStatus}field={field}runtimeValue={runtimeValue}- scaleLockNodePath={nodePath}fixHref="https://www.remotion.dev/docs/studio/interactivity-best-practices#keep-editable-values-visible"/>);diff --git a/packages/studio/src/test/timeline-field-utils.test.ts b/packages/studio/src/test/timeline-field-utils.test.tsindex 40c4592877..de4710e23d 100644--- a/packages/studio/src/test/timeline-field-utils.test.ts+++ b/packages/studio/src/test/timeline-field-utils.test.ts@@ -153,6 +153,19 @@ test('formatTimelineFieldValueForDisplay rounds unknown numeric fallbacks', () =).toBe('10');});+test('formatTimelineFieldValueForDisplay formats computed enum values as text', () => {+ expect(+ formatTimelineFieldValueForDisplay({+ fieldSchema: {+ type: 'enum',+ default: '400',+ variants: {'300': {}, '400': {}},+ },+ value: 300,+ }),+ ).toBe('300');+});+test('formatTimelineFieldValueForDisplay shows undefined schema values as unset', () => {expect(formatTimelineFieldValueForDisplay({diff --git a/packages/studio/src/test/timeline-keyframe-navigation.test.ts b/packages/studio/src/test/timeline-keyframe-navigation.test.tsindex e815899900..912aa287b7 100644--- a/packages/studio/src/test/timeline-keyframe-navigation.test.ts+++ b/packages/studio/src/test/timeline-keyframe-navigation.test.ts@@ -86,6 +86,7 @@ test('timeline keyframe controls visibility follows property selection or keyfraposterize: undefined,output: undefined,};+ const computedStatus: CanUpdateSequencePropStatus = {status: 'computed'};expect(shouldShowTimelineKeyframeControls({@@ -115,6 +116,13 @@ test('timeline keyframe controls visibility follows property selection or keyfrakeyframable: false,}),).toBe(false);+ expect(+ shouldShowTimelineKeyframeControls({+ propStatus: computedStatus,+ selected: true,+ keyframable: true,+ }),+ ).toBe(true);});test('keyframe navigation visibility follows property selection or keyframed status', () => {@@ -133,6 +141,7 @@ test('keyframe navigation visibility follows property selection or keyframed staposterize: undefined,output: undefined,};+ const computedStatus: CanUpdateSequencePropStatus = {status: 'computed'};expect(shouldShowTimelineKeyframeNavigation({@@ -152,4 +161,10 @@ test('keyframe navigation visibility follows property selection or keyframed staselected: false,}),).toBe(true);+ expect(+ shouldShowTimelineKeyframeNavigation({+ propStatus: computedStatus,+ selected: true,+ }),+ ).toBe(false);});