Repository navigation
fix: the objects added while a drawing tool is in use are frozen - #206
Merged
Merged
Conversation
The tools which draw a shape or pan freeze the objects of the canvas when they take over, but not the ones added afterwards: an image from addImg(), a text from addText(), a pasted object, and one which undo brings back were selectable. A press on an image with the arrow tool selected it, and a drag moved it instead of drawing the arrow. The tools get isInteractive(), and the events manager freezes what is added while the tool in use is not interactive. The select tool unfreezes all of them when it takes over, as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
With the arrow tool selected, an image loaded from a URL was selectable, and a press on it with the arrow tool selected it and a drag moved it, instead of drawing the arrow.
The tools which draw a shape or pan (line, arrow, rectangle, rectangle label, circle, polygon, pan and the default tool) freeze the objects of the canvas when they take over (
setInteractive(false)), but not the ones added afterwards. Those were selectable and evented, as fabric makes them: an image fromaddImg(), a text fromaddText(), a pasted object, and one which undo brings back. It is the same cause as the arrow fix of #200, now for the objects which are not drawn by the tool.isInteractive(), which is false aftersetInteractive(false).selectableandeventedfalse) what is added while the tool in use is not interactive. It does that for each added object, also for the ones of a pasted selection and the ones which undo and redo add back.Checks
yarn format:check,yarn lint,yarn typecheckandyarn buildpass.yarn test: 446 passing and 1 todo. The new tests inaddedObjects.spec.tsx(12) fail without the change, 11 of them: an image and a text with each of the 8 tools, the tools which stay selectable, the select tool taking over, a drag of an arrow from an image with the events of the browser (the image does not move, nothing is selected, the arrow is drawn), and a paste and an undo with the arrow tool.The steps of the report in the built showcase, in headless Chrome with a real mouse (a new canvas, the arrow tool, "Load Image from URL", a drag from the middle of the image): without the change the image was selected and moved (its top left from 71,112 to 144,141) and "Delete selected" was enabled; with it the image stays where it was, only the arrow is added, and nothing is selected.
Not checked: a physical touch device.
Notes for review
selectableandeventedare not intoJSON()(checked), so freezing the objects changes nothing in the saved value. A loaded value is frozen by the tool in use, as before.