Decide whether or not Quill will handle the copy event THEN preventDefault. #4573
+1
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #4572
The issue was an order of operations. Whenever the clipboard module captures a copy event it calls
preventDefault()
on it before it actually decides to do anything with the event.This PR just moves the call to
preventDefault()
after the clipboard module decides to handle it.In the case where the user selects the contents before, including, and after the quill root, the
onCopyCapture
handler doesn't get called, because some parent node handles the copy event.In the case where the user selects only text within the quill root,
this.quill.selection.getRange()
is able to return a valid range.However in cases where selection goes off the end of the quill root
this.quill.selection.getRange()
returnsnull
, resulting in a copy handler that prevents default AND doesn't handle the copy.