Skip to content

Commit

Permalink
PR: Text selection during the drag-n-drop (Safari, again) (#6973)
Browse files Browse the repository at this point in the history
* work for the surveyjs/private-tasks#284

* work for the surveyjs/private-tasks#284

* work for the surveyjs/private-tasks#284 (review-1)
  • Loading branch information
dmitry-kurmanov committed Sep 19, 2023
1 parent 487d538 commit 748d579
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/dragdrop/dom-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ export class DragDropDOMAdapter implements IDragDropDOMAdapter {
this.currentX = pointerMoveEvent.pageX;
this.currentY = pointerMoveEvent.pageY;
if (this.isMicroMovement) return;
document.body.style.setProperty("touch-action", "");
document.body.style.setProperty("user-select", "");
document.body.style.setProperty("-webkit-user-select", "");
this.returnUserSelectBack();
this.stopLongTap();
};
// see https://stackoverflow.com/questions/6042202/how-to-distinguish-mouse-click-and-drag
Expand All @@ -81,8 +79,7 @@ export class DragDropDOMAdapter implements IDragDropDOMAdapter {
this.startX = event.pageX;
this.startY = event.pageY;
document.body.style.setProperty("touch-action", "none", "important");
document.body.style.setProperty("user-select", "none", "important");
document.body.style.setProperty("-webkit-user-select", "none", "important");
document.body.style.setProperty("-webkit-touch-callout", "none", "important");

this.timeoutID = setTimeout(() => {
this.doStartDrag(
Expand Down Expand Up @@ -281,9 +278,7 @@ export class DragDropDOMAdapter implements IDragDropDOMAdapter {
this.savedTargetNode = null;
this.savedTargetNodeParent = null;

document.body.style.setProperty("touch-action", "");
document.body.style.setProperty("user-select", "");
document.body.style.setProperty("-webkit-user-select", "");
this.returnUserSelectBack();
};
private drop = () => {
this.dd.drop();
Expand Down Expand Up @@ -316,10 +311,19 @@ export class DragDropDOMAdapter implements IDragDropDOMAdapter {
}
}

private returnUserSelectBack() {
document.body.style.setProperty("touch-action", "auto");
document.body.style.setProperty("user-select", "auto");
document.body.style.setProperty("-webkit-user-select", "auto");
document.body.style.setProperty("-webkit-touch-callout", "default");
}

public draggedElementShortcut: any = null;
public rootContainer: HTMLElement;

public startDrag(event: PointerEvent, draggedElement: any, parentElement?: any, draggedElementNode?: HTMLElement, preventSaveTargetNode: boolean = false): void {
document.body.style.setProperty("user-select", "none", "important");
document.body.style.setProperty("-webkit-user-select", "none", "important");
if (IsTouch) {
this.startLongTapProcessing(
event,
Expand Down

0 comments on commit 748d579

Please sign in to comment.