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

Fix: Clarify separation between plain and comment highlights #58

Merged
merged 3 commits into from
Dec 4, 2017

Conversation

pramodsum
Copy link
Contributor

@pramodsum pramodsum commented Dec 1, 2017

  • Using the last annotation to determine whether or not the current annotation is of a valid and enabled type is problematic because because highlight comment annotations may have a plain highlight as the first annotation in the thread, resulting in a false positive for the thread.
  • Fixes bug where both highlight and comment buttons were displayed in the create dialog despite only plain highlights being enabled

@boxcla
Copy link

boxcla commented Dec 1, 2017

Verified that @pramodsum has signed the CLA. Thanks for the pull request!

@@ -79,8 +79,8 @@ class CreateHighlightDialog extends CreateAnnotationDialog {
constructor(parentEl, config = {}) {
super(parentEl, config);

this.allowHighlight = !!config.allowHighlight || true;
this.allowComment = !!config.allowComment || true;
this.allowHighlight = config.allowHighlight || false;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes bug where both highlight and comment buttons were displayed in the create dialog despite only plain highlights being enabled

@@ -542,13 +546,9 @@ class Annotator extends EventEmitter {

const pageThreads = this.threads[pageNum] || {};
Object.keys(pageThreads).forEach((threadID) => {
const thread = pageThreads[threadID];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Annotations with disabled types should be filtered out by this point so this extra check is unecessary

@@ -79,8 +79,8 @@ class CreateHighlightDialog extends CreateAnnotationDialog {
constructor(parentEl, config = {}) {
super(parentEl, config);

this.allowHighlight = !!config.allowHighlight || true;
this.allowComment = !!config.allowComment || true;
this.allowHighlight = config.allowHighlight || false;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also @JustinHoldstock thoughts on disabling these buttons by default? It feels weird to enable buttons if no config is passed in, however I guess that could result in an empty dialog showing up if nothing is passed in...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO Things should be enabled by default, if they're necessary for preventing developer confusion, and selectively disabled

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is more of a safety check (we make sure to never create a CreateHighlightDialog if !docAnnotator.plainHighlightEnabled && !docAnnotator.commentHighlightEnabled, this is more just a safety net.

*/
export function getLastAnnotation(annotations) {
const numAnnotations = Object.keys(annotations).length;
const lastAnnotationID = Object.keys(annotations)[numAnnotations - 1];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you bail out early if there are no annotations?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's necessary in this or the getFirstAnnotation() method since neither are costly calls. Curious as to the reason why we should be bailing out early?

@pramodsum pramodsum merged commit 496ceec into box:master Dec 4, 2017
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

Successfully merging this pull request may close these issues.

3 participants