Fabric.js: ERROR transform.actionHandler is not a function when using only Custom controls

Created on 24 Jul 2020  路  7Comments  路  Source: fabricjs/fabric.js

Version

4.0.0-beta.12

Test Case

https://jsfiddle.net/ckitisak/kzd6Lufa/

Information

Let say I have create a circle object and remove all default controls by replacing them with 2 custom controls call "save" and "cancel". When I clicked on the cancel control sometimes the error Uncaught TypeError: transform.actionHandler is not a function appears on console log before arrives to mouseUpHandler callback of the custom control as you can see in the screenshot below so how to prevent the error like this?

for more information please see in SO here

Steps to reproduce

  1. click on Edit button
  2. (optional) Move the object
  3. click cancel control (red with x)
  4. repeat step 1 - 3 (if error does not appear)

Expected Behavior

Actual Behavior

bug

All 7 comments

you should add the action handler as a noop.
We could embed it too, but yes, controls are supposed to have an action as of now.

Maybe we can add noop in the prototype and call it fixed?

@asturur Thank you for a quick reply. I'm not sure about what you have mentioned "noop". Would you please explain a little bit more or guided me where to change or update?

noop = no operation. Is an empty function. () => {} or function() {}

Is also available from lodash with this name.

After I added noop actionHandler like below. the error seem to be gone now. Thank you.

new fabric.Control({
    x: 1,
    y: -1.5,
    offsetY: 16,
    cursorStyle: 'pointer',
    mouseUpHandler: cancel,
    actionHandler: ()=>{},
    render: renderIcon,
    cornerSize: 24
  });

We can fix the control prototype so that this is not necessary.

@CKitisak i verified and in the version rc1, this empty action handler already exist.
So we already fixed, but you were using beta12 instead of the newer one.

@asturur thank you I will switch to the rc1 version.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

semiadam picture semiadam  路  3Comments

mlev picture mlev  路  3Comments

zhangzhzh picture zhangzhzh  路  4Comments

semiadam picture semiadam  路  3Comments

bhaskardas9475 picture bhaskardas9475  路  4Comments