diff --git a/apps/readest-app/src/app/reader/components/annotator/AnnotationRangeEditor.tsx b/apps/readest-app/src/app/reader/components/annotator/AnnotationRangeEditor.tsx index 958dfdd6..a20f9943 100644 --- a/apps/readest-app/src/app/reader/components/annotator/AnnotationRangeEditor.tsx +++ b/apps/readest-app/src/app/reader/components/annotator/AnnotationRangeEditor.tsx @@ -161,7 +161,6 @@ const AnnotationRangeEditor: React.FC = ({ const { handlePositions, getHandlePositionsFromRange, handleAnnotationRangeChange } = useAnnotationEditor({ bookKey, annotation, getAnnotationText, setSelection }); - const initializedRef = useRef(false); const handleColorHex = getHighlightColorHex(settings, handleColor) ?? '#FFFF00'; const draggingRef = useRef<'start' | 'end' | null>(null); const dragPointerTypeRef = useRef(''); @@ -173,9 +172,6 @@ const AnnotationRangeEditor: React.FC = ({ const [loupePoint, setLoupePoint] = useState(null); useEffect(() => { - if (initializedRef.current) return; - initializedRef.current = true; - const range = selection.range; const positions = getHandlePositionsFromRange(range, isVertical); if (positions) { diff --git a/apps/readest-app/src/app/reader/components/annotator/Annotator.tsx b/apps/readest-app/src/app/reader/components/annotator/Annotator.tsx index 7ada5adf..29e36d03 100644 --- a/apps/readest-app/src/app/reader/components/annotator/Annotator.tsx +++ b/apps/readest-app/src/app/reader/components/annotator/Annotator.tsx @@ -161,13 +161,12 @@ const Annotator: React.FC<{ bookKey: string }> = ({ bookKey }) => { }, [selection, bookKey, viewSettings.vertical]); useEffect(() => { - setSelectedStyle(settings.globalReadSettings.highlightStyle); + const highlightStyle = settings.globalReadSettings.highlightStyle; + setSelectedStyle(highlightStyle); + setSelectedColor(settings.globalReadSettings.highlightStyles[highlightStyle]); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [settings.globalReadSettings.highlightStyle]); - useEffect(() => { - setSelectedColor(settings.globalReadSettings.highlightStyles[selectedStyle]); - }, [settings.globalReadSettings.highlightStyles, selectedStyle]); - const transformCtx: TransformContext = useMemo( () => ({ bookKey, @@ -373,6 +372,8 @@ const Annotator: React.FC<{ bookKey: string }> = ({ bookKey }) => { setHighlightOptionsVisible(false); setEditingAnnotation(null); } else { + setShowAnnotPopup(false); + setEditingAnnotation(null); setShowAnnotationNotes(false); setAnnotationNotes([]); if (style && color) { @@ -612,6 +613,8 @@ const Annotator: React.FC<{ bookKey: string }> = ({ bookKey }) => { if (!cfi) return; const style = highlightStyle || settings.globalReadSettings.highlightStyle; const color = settings.globalReadSettings.highlightStyles[style]; + setSelectedStyle(style); + setSelectedColor(color); const annotation: BookNote = { id: uniqueId(), type: 'annotation',