Skip to content

Commit 0dc5bcc

Browse files
authored
Fix undo/redo history not working after panning or pinch-zoom gesture on touch devices (#107)
1 parent d847425 commit 0dc5bcc

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
66
## [Unreleased]
77
#### 🐛 Fixed
88
- Fix `AnnotationSupport` not unsubscribing from `AnnotationTopic` at unmount which causes tow annotations to be created from `SelectionActionAnnotate` in React development mode.
9+
- Fix undo/redo history not working after panning or pinch-zoom gesture on touch devices.
910

1011
## [0.31.1] - 2025-11-18
1112
#### 🐛 Fixed

src/diagram/paperArea.tsx

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -647,23 +647,25 @@ export class PaperArea extends React.Component<PaperAreaProps, State> implements
647647
document.removeEventListener('pointermove', this.onPointerMove);
648648
document.removeEventListener('pointerup', this.onPointerUp);
649649
document.removeEventListener('pointercancel', this.onPointerCancel);
650-
}
651650

652-
if (e && movingState && !movingState.pinchOrigin) {
653-
const {pointerMoved, target, batch, restoreGeometry} = movingState;
654-
this.source.trigger('pointerUp', {
655-
source: this,
656-
sourceEvent: e,
657-
target,
658-
panning: Boolean(movingState.panningOrigin),
659-
triggerAsClick: !pointerMoved,
660-
});
651+
const {pointerMoved, target, batch, restoreGeometry, pinchOrigin} = movingState;
652+
if (e && !pinchOrigin) {
653+
this.source.trigger('pointerUp', {
654+
source: this,
655+
sourceEvent: e,
656+
target,
657+
panning: Boolean(movingState.panningOrigin),
658+
triggerAsClick: !pointerMoved,
659+
});
661660

662-
const restore = restoreGeometry.filterOutUnchanged();
663-
if (restore.hasChanges()) {
664-
batch.history.registerToUndo(restore);
661+
const restore = restoreGeometry.filterOutUnchanged();
662+
if (restore.hasChanges()) {
663+
batch.history.registerToUndo(restore);
664+
}
665+
batch.store();
666+
} else {
667+
batch.discard();
665668
}
666-
batch.store();
667669
}
668670
};
669671

0 commit comments

Comments
 (0)