mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-11 06:30:03 +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 {
|
||||
const trackStyle = getTimelineTrackStyle(tag);
|
||||
const normalized = tag.toLowerCase();
|
||||
if (!tag) console.warn("[Timeline] getTrackStyle received empty tag, defaulting to div");
|
||||
const safeTag = tag || "div";
|
||||
const trackStyle = getTimelineTrackStyle(safeTag);
|
||||
const normalized = safeTag.toLowerCase();
|
||||
const icon =
|
||||
normalized.startsWith("h") && normalized.length === 2 && "123456".includes(normalized[1] ?? "")
|
||||
? ICONS.h1
|
||||
|
||||
Reference in New Issue
Block a user