Skip to content

Commit 2ee2f96

Browse files
Added opening on the bound's presence
1 parent e427223 commit 2ee2f96

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

packages/text-annotator-react/src/TextAnnotationPopup/TextAnnotationPopup.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { ReactNode, useEffect, useMemo, useRef, useState } from 'react';
22
import { useAnnotator, useSelection } from '@annotorious/react';
33
import {
4-
isRevived,
54
NOT_ANNOTATABLE_CLASS,
65
denormalizeRectWithOffset,
76
toDomRectList,
@@ -97,9 +96,13 @@ export const TextAnnotationPopup = (props: TextAnnotationPopupProps) => {
9796
const { getFloatingProps } = useInteractions([dismiss, role]);
9897

9998
useEffect(() => {
100-
const annotationSelector = annotation?.target.selector;
101-
setOpen(annotationSelector?.length > 0 ? isRevived(annotationSelector) : false);
102-
}, [annotation]);
99+
if (annotation?.id) {
100+
const bounds = r?.state.store.getAnnotationBounds(annotation.id);
101+
setOpen(Boolean(bounds));
102+
} else {
103+
setOpen(false);
104+
}
105+
}, [annotation?.id, r?.state.store]);
103106

104107
useEffect(() => {
105108
if (!r) return;

0 commit comments

Comments
 (0)