-
-
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(): Draggable Text Migration Regression #8534
Conversation
Build Stats
|
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.
READY!
9ec6440 can be reverted if you think isIdentityMatrix
should remain internal
// prepare instance for drag image snapshot by making all non selected text invisible | ||
const bgc = this.backgroundColor; | ||
const styles = object.clone(this.styles, true); | ||
const styles = clone(this.styles, true); |
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.
bug from #8421
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.
happened due to use of the transformer and no test to discover it
src/mixins/itext_behavior.mixin.ts
Outdated
@@ -679,7 +686,8 @@ export abstract class ITextBehaviorMixin< | |||
* @param {object} options | |||
* @param {DragEvent} options.e | |||
*/ | |||
dragOverHandler({ e }: TEvent<DragEvent>) { | |||
dragOverHandler(ev: TEvent<DragEvent>) { |
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.
same
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.
happened because no test
src/mixins/itext_behavior.mixin.ts
Outdated
*/ | ||
dropHandler({ e }: TEvent<DragEvent>) { | ||
dropHandler(ev: TEvent<DragEvent>) { |
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.
same
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.
happened because no test
@@ -106,6 +106,7 @@ export abstract class ITextClickBehaviorMixin< | |||
if ( | |||
!this.canvas || | |||
!this.editable || | |||
this.__isDragging || |
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.
bug from #8013
Found thanks to Git + VSCODE merge conflict UX!!
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.
merge conflict
src/mixins/itext_behavior.mixin.ts
Outdated
ctx.scale(1 / retinaScaling, 1 / retinaScaling); | ||
const [a, b, c, d] = vpt; | ||
const origin = new Point().transform(vpt, true); | ||
ctx.transform(a, b, c, d, -origin.x, -origin.y); |
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.
fix drag image vpt
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 is a fix to a bug unrelated to the migration
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.
added test
now it is possible to see there is a blur in the drag image.
no idea how to handle it
I didn't see this PR here. |
I commented all fixes and changes and referenced where they originated from. |
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.
Added tests
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 prefer changes to be made there instead of porting. |
For the blur in the dragged image i can fix it, i think the principle is the same as retina scaling |
Doing this today and the next, now i have guests i ll be off some hours |
@@ -283,6 +283,18 @@ export class IText extends ITextClickBehaviorMixin<ITextEvents> { | |||
this.renderCursorOrSelection(); | |||
} | |||
|
|||
/** | |||
* @override block cursor/selection logic while rendering the exported canvas | |||
* @todo this workaround should be replaced with a more robust solution |
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 made years ago a renderExport function for those cases.
I would run the usual render code but without side effects and without runing the current caches and with less blur.
I should officialize it, it covers also those cases.
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 is fine anyway
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 am for. An object should have a method for that.
BTW #8298 offers a solution as well.
@@ -192,6 +195,8 @@ export abstract class ITextClickBehaviorMixin< | |||
return; | |||
} | |||
|
|||
shouldSetCursor && this.setCursorByClick(options.e); |
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.
What is unclear to me is why this shouldn't have triggered on mouse down.
Not a big deal, this is not relevant to merging.
Can you try to explain anyway this is here? Setting cursor was usually mouse down tas
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 see the mouseDown has an extra this.__isDragging ||
how do we trigger dragging before mouse down event?
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.
_mouseDownHandlerBefore
sets this.__isDragging
to keep selection, it is clearer in #8598
fabric.js/src/mixins/DraggableTextDelegate.ts
Lines 12 to 21 in 27dcd9e
/** | |
* #### Dragging IText/Textbox Lifecycle | |
* - {@link start} is called from `mousedown:before` {@link IText#_mouseDownHandlerBefore} and determines if dragging should start by testing {@link isPointerOverSelection} | |
* - if true `mousedown` {@link IText#_mouseDownHandler} is blocked to keep selection | |
* - if the pointer moves, canvas fires numerous mousemove {@link Canvas#_onMouseMove} that we make sure **aren't** prevented ({@link IText#shouldStartDragging}) in order for the window to start a drag session | |
* - once/if the session starts canvas calls {@link onDragStart} on the active object to determine if dragging should occur | |
* - canvas fires relevant drag events that are handled by the handlers defined in this scope | |
* - {@link end} is called from `mouseup` {@link IText#mouseUpHandler}, blocking IText default click behavior | |
* - in case the drag session didn't occur, {@link end} handles a click, since logic to do so was blocked during `mousedown` | |
*/ |
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.
ok. so mosedown:before shoud allow for the developer to interact before fabric does anything.
That was the point of that event.
Let's try to not break that contract.
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.
So you suggest moving logic to mouse down?
Sounds correct
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 do think yes. But please let this idea at rest now we have other stuff to do |
I don't think the DOM will let us retarget an event. History isn't hard to impl by yourself, dragging is. So I am OK with it. |
I m sure you can clone events and forward them where you want, i did so in the past to have a layer that was capturing some events but setting others to a sibling below |
Motivation
Description
Draggable text was broken in #8013 (db8739a) and #8421 (due to
ts-nocheck
)Changes
Gist
I have noticed that undoing a text drop isn't supported natively and I wonder why. Would love your feedback.
The textarea value is changed programmatically on drop. Is there a way to do that and have the change enter the native history stack?
In Action
My screen recorder doesn't record the drag image... so it is pointless