🎥 Make videos programmatically with React
make expansion work correctly
JonnyBurger55c33dac3ff7
diff --git a/packages/studio-shared/src/index.ts b/packages/studio-shared/src/index.tsindex e76ee45eea..aca6e020f0 100644--- a/packages/studio-shared/src/index.ts+++ b/packages/studio-shared/src/index.ts@@ -122,3 +122,4 @@ export type {VisualControlChange} from './codemods';export {optimisticUpdateForCodeValues} from './optimistic-update-for-code-values';export {optimisticUpdateForEffectCodeValues} from './optimistic-update-for-effect-code-values';export {stringifySequenceSubscriptionKey} from './stringify-sequence-subscription-key';+export {stringifySequenceExpandedRowKey} from './stringify-sequence-subscription-key';diff --git a/packages/studio-shared/src/stringify-sequence-subscription-key.ts b/packages/studio-shared/src/stringify-sequence-subscription-key.tsindex 45b5b8d8f5..e113e7e5bf 100644--- a/packages/studio-shared/src/stringify-sequence-subscription-key.ts+++ b/packages/studio-shared/src/stringify-sequence-subscription-key.ts@@ -5,3 +5,10 @@ export const stringifySequenceSubscriptionKey = (): string => {return `${key.absolutePath}:${JSON.stringify(key.nodePath)}:${key.sequenceKeys.join('\0')}:${key.effectKeys.map((keys) => keys.join('\0')).join('\0\0')}`;};++// deliberately not including effect keys, keeping expanded if changing effects+export const stringifySequenceExpandedRowKey = (+ key: SequencePropsSubscriptionKey,+): string => {+ return `${key.absolutePath}:${JSON.stringify(key.nodePath)}:${key.sequenceKeys.join('\0')}`;+};diff --git a/packages/studio/src/components/ExpandedTracksProvider.tsx b/packages/studio/src/components/ExpandedTracksProvider.tsxindex f0d732b6c1..df48e7e9f0 100644--- a/packages/studio/src/components/ExpandedTracksProvider.tsx+++ b/packages/studio/src/components/ExpandedTracksProvider.tsx@@ -1,10 +1,10 @@-import {stringifySequenceSubscriptionKey} from '@remotion/studio-shared';+import {stringifySequenceExpandedRowKey} from '@remotion/studio-shared';import React, {createContext, useCallback, useMemo, useState} from 'react';import type {SequenceNodePathInfo} from '../helpers/get-timeline-sequence-sort-key';-const nodePathInfoToKey = (info: SequenceNodePathInfo): string =>+const nodePathInfoToExpandedKey = (info: SequenceNodePathInfo): string =>[- stringifySequenceSubscriptionKey(info.sequenceSubscriptionKey),+ stringifySequenceExpandedRowKey(info.sequenceSubscriptionKey),info.auxiliaryKeys.join('.'),info.index,].join('.');@@ -65,7 +65,7 @@ export const ExpandedTracksProvider: React.FC<{const toggleTrack = useCallback((nodePathInfo: SequenceNodePathInfo) => {setExpandedTracks((prev) => {- const key = nodePathInfoToKey(nodePathInfo);+ const key = nodePathInfoToExpandedKey(nodePathInfo);const next = {...prev, [key]: !prev[key]};window.localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(next));return next;@@ -75,7 +75,7 @@ export const ExpandedTracksProvider: React.FC<{const getterValue = useMemo((): ExpandedTracksGetterContextValue => ({getIsExpanded: (nodePathInfo) =>- expandedTracks[nodePathInfoToKey(nodePathInfo)] ?? false,+ expandedTracks[nodePathInfoToExpandedKey(nodePathInfo)] ?? false,}),[expandedTracks],);