Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overlapping highlights prevent adder from appearing #466

Closed
mwidner opened this issue Dec 9, 2014 · 2 comments
Closed

Overlapping highlights prevent adder from appearing #466

mwidner opened this issue Dec 9, 2014 · 2 comments

Comments

@mwidner
Copy link

mwidner commented Dec 9, 2014

Using the latest 1.2 branch, when you select a range that already has more than 1 highlight on it and the range is entirely within those highlights, the button to add another annotation does not appear. A quick scan of the code looks like getSelectedRanges() is ignoring this range? If someone can point me in the right direction, I'm happy to try and fix it and send a pull request. Thanks.

@mwidner
Copy link
Author

mwidner commented Dec 9, 2014

I've managed to fix this on my site with this change:

diff --git a/src/annotator.coffee b/src/annotator.coffee
index e2693c2..871f2bf 100644
--- a/src/annotator.coffee
+++ b/src/annotator.coffee
@@ -573,7 +573,7 @@ class Annotator extends Delegator

     for range in @selectedRanges
       container = range.commonAncestor
-      if $(container).hasClass('annotator-hl')
+      while $(container).hasClass('annotator-hl')
         container = $(container).parents('[class!=annotator-hl]')[0]
       return if this.isAnnotator(container)

I've tested it with 7-8 levels of overlapping annotations without problem. This is on v1.2.9.

@tilgovi
Copy link
Member

tilgovi commented Dec 9, 2014

@mwidner would you like to submit a pull request and we can add a test? I am happy to help.

This was referenced Dec 9, 2014
tilgovi added a commit that referenced this issue Jan 17, 2015
The `isAnnotator` method can ignore the highlight spans, making it a
simple call to `isAnnotator` when ignoring selections, rather than a
loop that tries to escape the highlights.

Close #466
@tilgovi tilgovi closed this as completed Feb 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants