Skip to content

Commit 68f008f

Browse files
committed
fix(studio): guard against null tag in timeline track style
getTrackStyle() can receive a falsy tag at runtime (e.g. empty string from timeline element defaults), causing toLowerCase() and startsWith() to throw. Default to "div" when tag is falsy.
1 parent f622e5a commit 68f008f

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

packages/studio/src/player/components/timelineIcons.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ const ICONS: Record<string, ReactNode> = {
3939
};
4040

4141
export function getTrackStyle(tag: string): TrackVisualStyle {
42-
const trackStyle = getTimelineTrackStyle(tag);
43-
const normalized = tag.toLowerCase();
42+
const safeTag = tag || "div";
43+
const trackStyle = getTimelineTrackStyle(safeTag);
44+
const normalized = safeTag.toLowerCase();
4445
const icon =
4546
normalized.startsWith("h") && normalized.length === 2 && "123456".includes(normalized[1] ?? "")
4647
? ICONS.h1

packages/studio/src/player/lib/timelineDOM.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export function createTimelineElementFromManifestClip(params: {
7272
const label = getTimelineElementDisplayLabel({
7373
id: clip.id,
7474
label: clip.label,
75-
tag: clip.tagName || clip.kind,
75+
tag: clip.tagName || clip.kind || "div",
7676
});
7777

7878
let domId: string | undefined;
@@ -103,7 +103,7 @@ export function createTimelineElementFromManifestClip(params: {
103103
id: identity.id,
104104
label,
105105
key: identity.key,
106-
tag: clip.tagName || clip.kind,
106+
tag: clip.tagName || clip.kind || "div",
107107
start: clip.start,
108108
duration: clip.duration,
109109
track: clip.track,

0 commit comments

Comments
 (0)