mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 04:38:33 +00:00
fix(studio): guard against null tag in timeline track style (#1679)
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.
This commit is contained in:
@@ -39,8 +39,10 @@ const ICONS: Record<string, ReactNode> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function getTrackStyle(tag: string): TrackVisualStyle {
|
export function getTrackStyle(tag: string): TrackVisualStyle {
|
||||||
const trackStyle = getTimelineTrackStyle(tag);
|
if (!tag) console.warn("[Timeline] getTrackStyle received empty tag, defaulting to div");
|
||||||
const normalized = tag.toLowerCase();
|
const safeTag = tag || "div";
|
||||||
|
const trackStyle = getTimelineTrackStyle(safeTag);
|
||||||
|
const normalized = safeTag.toLowerCase();
|
||||||
const icon =
|
const icon =
|
||||||
normalized.startsWith("h") && normalized.length === 2 && "123456".includes(normalized[1] ?? "")
|
normalized.startsWith("h") && normalized.length === 2 && "123456".includes(normalized[1] ?? "")
|
||||||
? ICONS.h1
|
? ICONS.h1
|
||||||
|
|||||||
@@ -61,6 +61,10 @@ export {
|
|||||||
// TimelineElement factories
|
// TimelineElement factories
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function resolveClipTag(clip: ClipManifestClip): string {
|
||||||
|
return clip.tagName || clip.kind || "div";
|
||||||
|
}
|
||||||
|
|
||||||
export function createTimelineElementFromManifestClip(params: {
|
export function createTimelineElementFromManifestClip(params: {
|
||||||
clip: ClipManifestClip;
|
clip: ClipManifestClip;
|
||||||
fallbackIndex: number;
|
fallbackIndex: number;
|
||||||
@@ -72,7 +76,7 @@ export function createTimelineElementFromManifestClip(params: {
|
|||||||
const label = getTimelineElementDisplayLabel({
|
const label = getTimelineElementDisplayLabel({
|
||||||
id: clip.id,
|
id: clip.id,
|
||||||
label: clip.label,
|
label: clip.label,
|
||||||
tag: clip.tagName || clip.kind,
|
tag: resolveClipTag(clip),
|
||||||
});
|
});
|
||||||
|
|
||||||
let domId: string | undefined;
|
let domId: string | undefined;
|
||||||
@@ -103,7 +107,7 @@ export function createTimelineElementFromManifestClip(params: {
|
|||||||
id: identity.id,
|
id: identity.id,
|
||||||
label,
|
label,
|
||||||
key: identity.key,
|
key: identity.key,
|
||||||
tag: clip.tagName || clip.kind,
|
tag: resolveClipTag(clip),
|
||||||
start: clip.start,
|
start: clip.start,
|
||||||
duration: clip.duration,
|
duration: clip.duration,
|
||||||
track: clip.track,
|
track: clip.track,
|
||||||
|
|||||||
Reference in New Issue
Block a user