fix(annotator): delay highlight action to prevent immediate onShowAnnotation trigger (#2820)

This commit is contained in:
Huang Xin
2025-12-31 08:35:26 +01:00
committed by GitHub
parent a42897ec5c
commit 22f9c45232
@@ -379,8 +379,12 @@ const Annotator: React.FC<{ bookKey: string }> = ({ bookKey }) => {
handleDismissPopupAndSelection();
break;
case 'highlight':
handleHighlight();
handleDismissPopupAndSelection();
// Delay to ensure highlight is applied after selection is set
// so that onShowAnnotation won't be triggered immediately
setTimeout(() => {
handleHighlight();
handleDismissPopupAndSelection();
}, 0);
break;
case 'dictionary':
handleDictionary();