Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [next]

- chore(): expose `__corner` => `getActiveControl()` [#9102](https://github.com/fabricjs/fabric.js/pull/9102)
- chore(TS) Add type-checking to files excluded with ts-nocheck ( Parser mostly ) [#9085](https://github.com/fabricjs/fabric.js/pull/9085)
- test(Text): Add some tests for text in Jest [#9083](https://github.com/fabricjs/fabric.js/pull/9083)
- ci(): Install system deps only when necessary [#9086](https://github.com/fabricjs/fabric.js/pull/9086)
Expand Down
2 changes: 1 addition & 1 deletion src/canvas/Canvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1479,7 +1479,7 @@ export class Canvas extends SelectableCanvas {
// target accepts selection
!target.onSelect({ e }) &&
// make sure we are not on top of a control
!activeObject.__corner
!activeObject.getActiveControl()
) {
if (isAS) {
const prevActiveObjects =
Expand Down
2 changes: 1 addition & 1 deletion src/canvas/SelectableCanvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ export class SelectableCanvas<
target.group.calcTransformMatrix()
)
: this.getPointer(e);
const corner = target.__corner || '',
const corner = target.getActiveControl() || '',
control = !!corner && target.controls[corner],
actionHandler =
alreadySelected && control
Expand Down
6 changes: 5 additions & 1 deletion src/shapes/IText/DraggableTextDelegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,11 @@ export class DraggableTextDelegate {
* @returns {boolean} determines whether {@link target} should/shouldn't become a drop target
*/
canDrop(e: DragEvent): boolean {
if (this.target.editable && !this.target.__corner && !e.defaultPrevented) {
if (
this.target.editable &&
!this.target.getActiveControl() &&
!e.defaultPrevented
) {
if (this.isActive() && this.__dragStartSelection) {
// drag source trying to drop over itself
// allow dropping only outside of drag start selection
Expand Down
2 changes: 1 addition & 1 deletion src/shapes/IText/ITextBehavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ export abstract class ITextBehavior<
* called by {@link canvas#textEditingManager}
*/
updateSelectionOnMouseMove(e: TPointerEvent) {
if (this.__corner) {
if (this.getActiveControl()) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/shapes/IText/ITextClickBehavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export abstract class ITextClickBehavior<
!this.canvas ||
!this.editable ||
notALeftClick(e as MouseEvent) ||
this.__corner
this.getActiveControl()
) {
return;
}
Expand Down Expand Up @@ -201,7 +201,7 @@ export abstract class ITextClickBehavior<
return;
}

if (this.__lastSelected && !this.__corner) {
if (this.__lastSelected && !this.getActiveControl()) {
this.selected = false;
this.__lastSelected = false;
this.enterEditing(e);
Expand Down
4 changes: 4 additions & 0 deletions src/shapes/Object/InteractiveObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ export class InteractiveFabricObject<
return super._updateCacheCanvas();
}

getActiveControl() {
return this.__corner
}

/**
* Determines which corner is under the mouse cursor, represented by `pointer`.
* This function is return a corner only if the object is the active one.
Expand Down