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(Canvas): safeguard canvas add #7866

Merged
merged 3 commits into from
Apr 5, 2022
Merged

fix(Canvas): safeguard canvas add #7866

merged 3 commits into from
Apr 5, 2022

Conversation

ShaMan123
Copy link
Contributor

removes object from previous canvas when adding to a new one

removes objet from previous canvas when adding to a new one
@ShaMan123 ShaMan123 changed the title fix(): safeguard canvas add fix(Canvas): safeguard canvas add Apr 5, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Apr 5, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |    50.5 |    41.17 |   48.42 |    50.1 |                                               
 fabric.js |    50.5 |    41.17 |   48.42 |    50.1 | ...-30547,30629,30691,30702-30705,30728-30752 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Apr 5, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   83.05 |    76.17 |   86.23 |   82.77 |                                               
 fabric.js |   83.05 |    76.17 |   86.23 |   82.77 | ...,30120,30194,30205-30270,30393,30492,30728 
-----------|---------|----------|---------|---------|-----------------------------------------------

@github-actions
Copy link
Contributor

github-actions bot commented Apr 5, 2022

Code Coverage Summary

> fabric@5.1.0 coverage:report
> nyc report --reporter=lcov --reporter=text

-----------|---------|----------|---------|---------|-----------------------------------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                             
-----------|---------|----------|---------|---------|-----------------------------------------------
All files  |   83.05 |    76.17 |   86.23 |   82.77 |                                               
 fabric.js |   83.05 |    76.17 |   86.23 |   82.77 | ...,30120,30194,30205-30270,30393,30492,30728 
-----------|---------|----------|---------|---------|-----------------------------------------------

'Resulting to default behavior: removing object from previous canvas and adding to new canvas');
/* _DEV_MODE_END_ */
obj.canvas.remove(obj);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this is totally fair, because the old reference in the canas would be just a broken reference.

i used this a couple of times to render objects in different canvases for copy purposes, the thing i was doing was to swap the canvas reference manually, while now i should go through the add/remove process and avoid extra renders.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to check for duplicates as well? I think it's damaging for perf and I don't see too much advantage for it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we do we can do in the dev mode braket and remove it in prod build.

@ShaMan123 ShaMan123 merged commit ddc87f8 into master Apr 5, 2022
@ShaMan123 ShaMan123 deleted the safeguard-canvas-add branch April 5, 2022 11:42
@ShaMan123
Copy link
Contributor Author

This exposed a regression for toCanvasElement.
PRing soon.

ShaMan123 added a commit that referenced this pull request Apr 26, 2022
#7866 exposed a regression when using `toCanvasElement`
This commit fixes it and fixes another issue:
`object.toCanvasElement()` would fire an added event which is absolutely undesired
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.

2 participants