Skip to content

🎥 Make videos programmatically with React

Revert "fix: preserve collapsed effect rows on selection (#8659)" (#8663)

Jonny Burger041411a5a35d
diff --git a/packages/studio/src/components/ExpandedTracksProvider.tsx b/packages/studio/src/components/ExpandedTracksProvider.tsx
index 18be8c22b3..a1e72646e5 100644
--- a/packages/studio/src/components/ExpandedTracksProvider.tsx
+++ b/packages/studio/src/components/ExpandedTracksProvider.tsx
@@ -1,6 +1,5 @@
import React, {createContext, useCallback, useMemo, useState} from 'react';
import type {SequencePropsSubscriptionKey} from 'remotion';
-import {getExpandedTrackParentKeys} from '../helpers/get-expanded-track-parent-keys';
import type {SequenceNodePathInfo} from '../helpers/get-timeline-sequence-sort-key';
import {migrateExpandedTracksForSubscriptionKey} from '../helpers/migrate-expanded-tracks-for-subscription-key';
import {timelineNodePathInfoToKey} from '../helpers/timeline-node-path-key';
@@ -101,7 +100,16 @@ export const ExpandedTracksProvider: React.FC<{
const expandParentTracks = useCallback(
(nodePathInfo: SequenceNodePathInfo) => {
- const keysToExpand = getExpandedTrackParentKeys(nodePathInfo);
+ const keysToExpand: string[] = [];
+
+ for (let i = 0; i < nodePathInfo.auxiliaryKeys.length; i++) {
+ keysToExpand.push(
+ timelineNodePathInfoToKey({
+ ...nodePathInfo,
+ auxiliaryKeys: nodePathInfo.auxiliaryKeys.slice(0, i),
+ }),
+ );
+ }
if (keysToExpand.length === 0) {
return;
diff --git a/packages/studio/src/helpers/get-expanded-track-parent-keys.ts b/packages/studio/src/helpers/get-expanded-track-parent-keys.ts
deleted file mode 100644
index 2957859ca7..0000000000
--- a/packages/studio/src/helpers/get-expanded-track-parent-keys.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import type {SequenceNodePathInfo} from './get-timeline-sequence-sort-key';
-import {timelineNodePathInfoToKey} from './timeline-node-path-key';
-
-export const getExpandedTrackParentKeys = (
- nodePathInfo: SequenceNodePathInfo,
-): string[] => {
- const keysToExpand: string[] = [];
- const parentDepth =
- nodePathInfo.auxiliaryKeys[0] === 'effects' &&
- nodePathInfo.auxiliaryKeys.length > 2
- ? 2
- : nodePathInfo.auxiliaryKeys.length;
-
- for (let i = 0; i < parentDepth; i++) {
- keysToExpand.push(
- timelineNodePathInfoToKey({
- ...nodePathInfo,
- auxiliaryKeys: nodePathInfo.auxiliaryKeys.slice(0, i),
- }),
- );
- }
-
- return keysToExpand;
-};
diff --git a/packages/studio/src/test/get-expanded-track-parent-keys.test.ts b/packages/studio/src/test/get-expanded-track-parent-keys.test.ts
deleted file mode 100644
index 964264ca0c..0000000000
--- a/packages/studio/src/test/get-expanded-track-parent-keys.test.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-import {expect, test} from 'bun:test';
-import {stringifySequenceExpandedRowKey} from '@remotion/studio-shared';
-import type {SequenceNodePath, SequencePropsSubscriptionKey} from 'remotion';
-import {getExpandedTrackParentKeys} from '../helpers/get-expanded-track-parent-keys';
-import type {SequenceNodePathInfo} from '../helpers/get-timeline-sequence-sort-key';
-
-const makeKey = (nodePath: SequenceNodePath): SequencePropsSubscriptionKey => ({
- absolutePath: '/project/src/Comp.tsx',
- nodePath,
- sequenceKeys: ['from', 'durationInFrames'],
- effectKeys: [],
-});
-
-const makeNodePathInfo = (
- nodePath: SequenceNodePath,
- auxiliaryKeys: string[],
-): SequenceNodePathInfo => ({
- sequenceSubscriptionKey: makeKey(nodePath),
- auxiliaryKeys,
- index: 0,
- numberOfSequencesWithThisNodePath: 1,
- supportsEffects: true,
-});
-
-const expandedKey = (
- subscriptionKey: SequencePropsSubscriptionKey,
- auxiliaryKeys: string[],
-) =>
- [
- stringifySequenceExpandedRowKey(subscriptionKey),
- auxiliaryKeys.join('.'),
- 0,
- ].join('.');
-
-test('expands regular parent rows for nested sequence props', () => {
- const nodePathInfo = makeNodePathInfo(
- ['body', 0],
- ['layout', 'position', 'x'],
- );
-
- expect(getExpandedTrackParentKeys(nodePathInfo)).toEqual([
- expandedKey(nodePathInfo.sequenceSubscriptionKey, []),
- expandedKey(nodePathInfo.sequenceSubscriptionKey, ['layout']),
- expandedKey(nodePathInfo.sequenceSubscriptionKey, ['layout', 'position']),
- ]);
-});
-
-test('preserves a collapsed effect row when selecting one of its props', () => {
- const nodePathInfo = makeNodePathInfo(
- ['body', 0],
- ['effects', '0', 'intensity'],
- );
-
- expect(getExpandedTrackParentKeys(nodePathInfo)).toEqual([
- expandedKey(nodePathInfo.sequenceSubscriptionKey, []),
- expandedKey(nodePathInfo.sequenceSubscriptionKey, ['effects']),
- ]);
-});