Skip to content

🎥 Make videos programmatically with React

Fix modifier double-click selection behavior (#7865)

Jonny Burger12c22b2ecf98
diff --git a/packages/studio/src/components/Timeline/TimelineListItem.tsx b/packages/studio/src/components/Timeline/TimelineListItem.tsx
index d95302d07c..06472d95b6 100644
--- a/packages/studio/src/components/Timeline/TimelineListItem.tsx
+++ b/packages/studio/src/components/Timeline/TimelineListItem.tsx
@@ -34,6 +34,7 @@ import {
} from './TimelineMediaInfo';
import {TimelineRowChrome} from './TimelineRowChrome';
import {
+ isTimelineSelectionModifierEvent,
SELECTION_ENABLED,
useTimelineRowContainsSelection,
useTimelineRowSelection,
@@ -318,6 +319,11 @@ export const TimelineListItem: React.FC<{
return;
}
+ if (isTimelineSelectionModifierEvent(e)) {
+ e.stopPropagation();
+ return;
+ }
+
e.stopPropagation();
openInEditor();
},
diff --git a/packages/studio/src/components/Timeline/TimelineSelection.tsx b/packages/studio/src/components/Timeline/TimelineSelection.tsx
index af7fe39b0e..4d68b6cbac 100644
--- a/packages/studio/src/components/Timeline/TimelineSelection.tsx
+++ b/packages/studio/src/components/Timeline/TimelineSelection.tsx
@@ -79,6 +79,18 @@ export type TimelineSelectionInteraction = {
readonly toggleKey: boolean;
};
+export const isTimelineSelectionModifierEvent = ({
+ shiftKey,
+ metaKey,
+ ctrlKey,
+}: {
+ readonly shiftKey: boolean;
+ readonly metaKey: boolean;
+ readonly ctrlKey: boolean;
+}) => {
+ return shiftKey || metaKey || ctrlKey;
+};
+
export type TimelineSelectionState = {
readonly selectedItems: readonly TimelineSelection[];
readonly anchor: TimelineSelection | null;
diff --git a/packages/studio/src/test/timeline-selection.test.ts b/packages/studio/src/test/timeline-selection.test.ts
index 1add7e3cf1..30ff59aa5e 100644
--- a/packages/studio/src/test/timeline-selection.test.ts
+++ b/packages/studio/src/test/timeline-selection.test.ts
@@ -6,6 +6,7 @@ import {
getSelectableTimelineSequenceSelections,
getTimelineSelectionAfterInteraction,
getTimelineSequenceSelectionKey,
+ isTimelineSelectionModifierEvent,
SELECTION_ENABLED,
TIMELINE_TOP_DRAG,
} from '../components/Timeline/TimelineSelection';
@@ -195,3 +196,34 @@ test('Shift+click with no matching anchor falls back to single selection', () =>
anchor: rowA,
});
});
+
+test('Timeline double-click actions ignore selection modifier clicks', () => {
+ expect(
+ isTimelineSelectionModifierEvent({
+ shiftKey: true,
+ metaKey: false,
+ ctrlKey: false,
+ }),
+ ).toBe(true);
+ expect(
+ isTimelineSelectionModifierEvent({
+ shiftKey: false,
+ metaKey: true,
+ ctrlKey: false,
+ }),
+ ).toBe(true);
+ expect(
+ isTimelineSelectionModifierEvent({
+ shiftKey: false,
+ metaKey: false,
+ ctrlKey: true,
+ }),
+ ).toBe(true);
+ expect(
+ isTimelineSelectionModifierEvent({
+ shiftKey: false,
+ metaKey: false,
+ ctrlKey: false,
+ }),
+ ).toBe(false);
+});