Skip to content
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

Fix object removal with custom code #3992

Merged
merged 2 commits into from
Jun 9, 2017
Merged

Conversation

nurbs999
Copy link
Contributor

@nurbs999 nurbs999 commented Jun 8, 2017

If objects get removed by custom code like this

fabric.Canvas.prototype.customiseControls({
    tr: {
        action: function( e, target ) {
            // bugfix for text elements in fabric
            let canvas = target.canvas;

            if (canvas.getActiveObject()) {
                canvas.remove(canvas.getActiveObject());
            }
            target.canvas = canvas;

            canvas.deactivateAll();
            canvas.renderAll();
            // do other important stuff after object was removed
        }
    }
}, function() {
});

fabricjs crashed because action is a function in this case.

@asturur
Copy link
Member

asturur commented Jun 8, 2017

i can accept action.slice && action.slice(...) actions functions are not part of fabric and i do not want to make it looks like they are.

@nurbs999
Copy link
Contributor Author

nurbs999 commented Jun 8, 2017

That will also work. I would really appreciate if you could make this change.
if (action.slice && action.slice(0, 5) === 'scale') {

@nurbs999 nurbs999 closed this Jun 8, 2017
@asturur
Copy link
Member

asturur commented Jun 8, 2017

can't you just do in this PR?

@nurbs999 nurbs999 reopened this Jun 9, 2017
@nurbs999
Copy link
Contributor Author

nurbs999 commented Jun 9, 2017

I changed the PR with the new commit.
I just have little experiance with PRs. How do I submit my PR to your master branch?

@asturur
Copy link
Member

asturur commented Jun 9, 2017

that's ok

@asturur asturur merged commit 3987c96 into fabricjs:master Jun 9, 2017
asturur pushed a commit that referenced this pull request Jun 9, 2017
@asturur
Copy link
Member

asturur commented Jun 9, 2017

be carefull that this is submitted to master branch and backported to 1.x

If you want to use this fix NOW or you add manyally to your build or you build from the 1.x branch.
I'll publish this fix and another fix in fabric 1.7.13 as soon as i have some time

@nurbs999
Copy link
Contributor Author

nurbs999 commented Jun 9, 2017

Thanks a lot.
I manually fixed this in my current dest build, too.

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.

3 participants