Skip to content

fix: the objects added while a drawing tool is in use are frozen - #206

Merged
tbolis merged 1 commit into
release/1.1.0from
fix/objects-added-while-drawing-are-frozen
Nov 2, 2026
Merged

tbolis merged 1 commit into
release/1.1.0from
fix/objects-added-while-drawing-are-frozen

Conversation

@tbolis

@tbolis tbolis commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

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 from addImg(), a text from addText(), 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.

  • The tools get isInteractive(), which is false after setInteractive(false).
  • The events manager freezes (selectable and evented false) 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.
  • The select tool makes all the objects selectable when it takes over, as before. The tools which draw free hand (pencil, highlighter, eraser, laser pointer) do not freeze, as fabric does not select an object in drawing mode.
  • README: a sentence in the tools table. CHANGELOG: an entry under Fixed in 1.1.0.

Checks

yarn format:check, yarn lint, yarn typecheck and yarn build pass. yarn test: 446 passing and 1 todo. The new tests in addedObjects.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

  • selectable and evented are not in toJSON() (checked), so freezing the objects changes nothing in the saved value. A loaded value is frozen by the tool in use, as before.

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.
@tbolis
tbolis merged commit 8128531 into release/1.1.0 Nov 2, 2026
3 checks passed
@tbolis
tbolis deleted the fix/objects-added-while-drawing-are-frozen branch November 2, 2026 11:01
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.

1 participant