-
Notifications
You must be signed in to change notification settings - Fork 7
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
#127 Made annotatingEnabled
property reactive
#128
base: main
Are you sure you want to change the base?
#127 Made annotatingEnabled
property reactive
#128
Conversation
dae32c7
to
da40d2c
Compare
const setAnnotatingEnabled = (enabled: boolean) => { | ||
currentAnnotatingEnabled = enabled; | ||
onSelectionChange.clear(); | ||
|
||
if (!enabled) { | ||
currentTarget = undefined; | ||
lastPointerDown = undefined; | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We must clean the onSelectionChange
debounced call to prevent it from running on obsolete values from the closure. Otherwise, the selectionchange
event will still get processed in the deferred call, even though the currentAnnotatingEnabled
became false
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder how crucial that is though. Would annotatingEnabled
get called during a selection in practice? The normal use cases I would see is:
- Setting it once on page init (because the user is getting a page served in "read-only mode")
- "Locking a page" interactively, by the user clicking a "Lock" button. (In which case there wouldn't be a selection.)
# Conflicts: # packages/text-annotator-react/src/TextAnnotator.tsx # packages/text-annotator/src/SelectionHandler.ts
# See - sindresorhus/debounce#8. The debounced function has a strict context comparison that breaks when applied in the resize listener
# Conflicts: # packages/text-annotator/src/SelectionHandler.ts
# Conflicts: # packages/text-annotator/src/TextAnnotator.ts
# Conflicts: # packages/text-annotator/src/SelectionHandler.ts # packages/text-annotator/src/TextAnnotator.ts # packages/text-annotator/src/highlight/baseRenderer.ts
# Conflicts: # packages/text-annotator/src/SelectionHandler.ts # packages/text-annotator/src/utils/index.ts
# Conflicts: # packages/text-annotator/src/SelectionHandler.ts
# Conflicts: # packages/text-annotator/src/utils/index.ts
# Conflicts: # packages/text-annotator/src/SelectionHandler.ts
# Conflicts: # packages/text-annotator/src/SelectionHandler.ts # packages/text-annotator/src/TextAnnotator.ts
# Conflicts: # packages/text-annotator/src/TextAnnotator.ts
Issue - #127
Changes Made
I made the
annotatingEnabled
a dynamic property that can receive values from the external sources via thesetAnnotatingEnabled
(following the "API addition: method to change userSelectAction" example)