diff --git a/CHANGELOG.md b/CHANGELOG.md index 394a671780a..64430c669d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## [next] +- fix(Canvas): Holding down Shift to select multiple shapes unexpectedly triggers the text exit event. [#10228](https://github.com/fabricjs/fabric.js/issues/10228) - fix(): mousedown restore after touch end on dospose [#10250](https://github.com/fabricjs/fabric.js/pull/10250) - feat(IText): expose getCursorRenderingData() function. [#10204](https://github.com/fabricjs/fabric.js/pull/10204) - fix(Canvas): allowTouchScrolling interactions [#10078](https://github.com/fabricjs/fabric.js/pull/10078) diff --git a/src/canvas/Canvas.spec.ts b/src/canvas/Canvas.spec.ts index c53fb24f98e..e3921ea0539 100644 --- a/src/canvas/Canvas.spec.ts +++ b/src/canvas/Canvas.spec.ts @@ -1,5 +1,7 @@ import { Canvas } from './Canvas'; import { Rect } from '../shapes/Rect'; +import { IText } from '../shapes/IText/IText'; +import '../shapes/ActiveSelection'; describe('Canvas', () => { describe('touchStart', () => { @@ -139,4 +141,31 @@ describe('Canvas', () => { ); }); }); + + describe('handleMultiSelection', () => { + const canvas = new Canvas(); + const rect = new Rect({ left: 100, width: 100, height: 100 }); + const iText = new IText('itext'); + canvas.add(rect, iText); + test('Selecting shapes containing text does not trigger the exit event', () => { + const exitMock = jest.fn(); + iText.on('editing:exited', exitMock); + + const firstClick = new MouseEvent('click', { + clientX: 0, + clientY: 0, + }); + canvas._onMouseDown(firstClick); + canvas._onMouseUp(firstClick); + const secondClick = new MouseEvent('click', { + shiftKey: true, + clientX: 100, + clientY: 0, + }); + canvas._onMouseDown(secondClick); + canvas._onMouseUp(secondClick); + + expect(exitMock).toHaveBeenCalledTimes(0); + }); + }); }); diff --git a/src/canvas/Canvas.ts b/src/canvas/Canvas.ts index 8c327e4512a..a7650521d2e 100644 --- a/src/canvas/Canvas.ts +++ b/src/canvas/Canvas.ts @@ -1446,7 +1446,7 @@ export class Canvas extends SelectableCanvas implements CanvasOptions { } this._fireSelectionEvents(prevActiveObjects, e); } else { - (activeObject as IText).exitEditing && + (activeObject as IText).isEditing && (activeObject as IText).exitEditing(); // add the active object and the target to the active selection and set it as the active object const klass =