diff --git a/enjoy/src/renderer/components/medias/media-caption.tsx b/enjoy/src/renderer/components/medias/media-caption.tsx
index d5fbfcc8..35ed5360 100644
--- a/enjoy/src/renderer/components/medias/media-caption.tsx
+++ b/enjoy/src/renderer/components/medias/media-caption.tsx
@@ -82,7 +82,7 @@ export const MediaCaption = () => {
setActiveRegion(region);
}
- activeRegion.remove();
+ activeRegion?.remove();
} else if (activeRegion.id.startsWith("meaning-group-region")) {
setActiveRegion(
regions.getRegions().find((r) => r.id.startsWith("segment-region"))
@@ -277,81 +277,74 @@ export const MediaCaption = () => {
{/* use the words splitted by caption text if it is matched with the timeline length, otherwise use the timeline */}
{caption.text.split(" ").length !== caption.timeline.length
? (caption.timeline || []).map((w, index) => (
-
toggleRegion(index)}
- >
-
-
- {w.text}
-
- {displayIpa && (
-
- {w.timeline
- .map((t) =>
- t.timeline
- .map((s) => convertIpaToNormal(s.text))
- .join("")
- )
- .join(" · ")}
-
- )}
+ onClick={() => toggleRegion(index)}
+ >
+
+
+ {w.text}
+ {displayIpa && (
+
+ {w.timeline
+ .map((t) =>
+ t.timeline
+ .map((s) => convertIpaToNormal(s.text))
+ .join("")
+ )
+ .join(" · ")}
+
+ )}
- ))
+
+ ))
: caption.text.split(" ").map((word, index) => (
-
toggleRegion(index)}
- >
-
-
- {word}
-
- {displayIpa && (
-
- {caption.timeline[index].timeline
- .map((t) =>
- t.timeline
- .map((s) => convertIpaToNormal(s.text))
- .join("")
- )
- .join(" · ")}
-
- )}
+ onClick={() => toggleRegion(index)}
+ >
+
+
+ {word}
+ {displayIpa && (
+
+ {caption.timeline[index].timeline
+ .map((t) =>
+ t.timeline
+ .map((s) => convertIpaToNormal(s.text))
+ .join("")
+ )
+ .join(" · ")}
+
+ )}
- ))}
+
+ ))}