-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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): toDataURL and toCanvasElement do not draw controls by default (skipControlsDrawing) #9896
Conversation
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
Build Stats
|
src/canvas/SelectableCanvas.ts
Outdated
options = {} as TToCanvasElementOptions | ||
): HTMLCanvasElement { | ||
const { keepControls } = options; | ||
const originalActive = this._activeObject; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assumes that only the activeObj has active controls, which is true for vanilla fabric but easily not-so in apps. And it feels hacky anyway. The way instead we did was to use the now-removed interactive
property when exporting the canvas and skip control rendering if true. For instance skipping canvas.drawControls()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but this.interactive does not exist anymore.
The issue is in the renderCanvas method that because render the controls in 2 moments of the function is not easily divisible in the static vs non static part.
I could also just add interactive back, it would be as hacky has this but less code probably
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's hacky as ultimately you need a condition to tell if the rendering is happening because of export and differentiate based on that. It can be called interactive
but also exporting
/static
whatever
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or could be called protected shouldRenderControls since is being built just for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a workaround as the other because the real issue is that the StaticCanvas shouldn't have an empty drawControls method to call because renderCanvas isn't correctly split between the 2 classes. If it was i could just call the part that does not render the controls
We do not need a boolean to render controls if not for this issue here. In that sense are both workarounds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also say that it should be left to the app deciding what to do. If you're using SelectableCanvas
and do not want to render controls, then just discard the activeObj before toCanvasElement()
.
I think determining when to render controls in general is highly app-specific.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes all good points, but when i have a sort of regression, i patch the issue, i take notes for improvement, but i don't like to do both at once. In this case the boolean will take care of both, but is a new feature introduced for a fix, and that is smells of problems to me, always.
….js into toCanvasElement-controls
Description
close #9846
Add an override for the canvas to hide the active object controls
Left as an option.
This will be completely useless when controls will be moved on the upper canvas.