File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed
packages/text-annotator/src Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -77,10 +77,25 @@ export const SelectionHandler = (
7777 const onSelectionChange = debounce ( ( evt : Event ) => {
7878 const sel = document . getSelection ( ) ;
7979
80- // This is to handle cases where the selection is "hijacked" by another element
81- // in a not-annotatable area. A rare case in theory. But rich text editors
82- // will like Quill do it...
83- if ( sel ?. anchorNode && isNotAnnotatable ( sel . anchorNode ) ) {
80+ /**
81+ * In iOS when a user clicks on a button, the `selectionchange` event is fired.
82+ * However, the generated selection is empty and the `anchorNode` is `null`.
83+ * That doesn't give us information about whether the selection is in the annotatable area
84+ * or whether the previously selected text was dismissed.
85+ * Therefore - we should bail out from such a range processing.
86+ *
87+ * @see https://github.com/recogito/text-annotator-js/pull/164#issuecomment-2416961473
88+ */
89+ if ( ! sel ?. anchorNode ) {
90+ return ;
91+ }
92+
93+ /**
94+ * This is to handle cases where the selection is "hijacked" by another element
95+ * in a not-annotatable area. A rare case in theory. But rich text editors
96+ * will like Quill do it...
97+ */
98+ if ( isNotAnnotatable ( sel . anchorNode ) ) {
8499 currentTarget = undefined ;
85100 return ;
86101 }
You can’t perform that action at this time.
0 commit comments