Skip to content

Commit

Permalink
Addresses #139 in the revised selection model
Browse files Browse the repository at this point in the history
  • Loading branch information
rsimon committed Sep 30, 2024
1 parent c14ed99 commit 9e3f045
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions packages/text-annotator/src/SelectionHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ export const SelectionHandler = (
store.deleteAnnotation(currentTarget.annotation);
}

currentTarget = undefined;

This comment has been minimized.

Copy link
@oleksandr-danylchenko

oleksandr-danylchenko Sep 30, 2024

Contributor

The currentTarget shouldn't be dismissed on the selection collapse, that will break the repeated mouse selection. See - #140 (comment)

This comment has been minimized.

Copy link
@rsimon

rsimon Sep 30, 2024

Author Member

Ah - got it, thanks. Then the proper way to handle it would be to re-check for a collapsed selection in the keyup handler, so that zero-size text selections get discarded. I added this here:
9461812


return;
}

Expand Down Expand Up @@ -144,21 +146,7 @@ export const SelectionHandler = (
// being edited. But it will typcially be the case on mobile!
if (store.getAnnotation(currentTarget.annotation)) {
store.updateTarget(currentTarget, Origin.LOCAL);
} /* else {
// Proper lifecycle management: clear selection first...
selection.clear();
// ...then add annotation to store...
store.addAnnotation({
id: currentTarget.annotation,
bodies: [],
target: currentTarget
});
// ...then make the new annotation the current selection
selection.userSelect(currentTarget.annotation, lastDownEvent);
}
*/
});

/**
Expand Down

0 comments on commit 9e3f045

Please sign in to comment.