Skip to content

Commit 85dbeac

Browse files
authored
Merge pull request #2093 from Gezdy/contenteditable
bug #2063: editable elements focus and blur correction
2 parents 772b635 + 5014538 commit 85dbeac

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/dd-draggable.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
134134
const name = (e.target as HTMLElement).nodeName.toLowerCase();
135135
if (skipMouseDown.find(skip => skip === name)) return true;
136136

137+
//for contenteditable
138+
if((e.target as HTMLElement).closest('[contenteditable="true"]')) return true;
139+
137140
// make sure we are clicking on a drag handle or child of it...
138141
// Note: we don't need to check that's handle is an immediate child, as mouseHandled will prevent parents from also handling it (lowest wins)
139142
//
@@ -153,8 +156,13 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
153156
this.dragEl.addEventListener('touchmove', touchmove);
154157
this.dragEl.addEventListener('touchend', touchend);
155158
}
156-
159+
157160
e.preventDefault();
161+
162+
//e.preventDefault() prevents blur event which occurs just after mousedown event.
163+
//if an editable content has focus, then blur must be call
164+
if(document.activeElement) (document.activeElement as HTMLElement).blur();
165+
158166
DDManager.mouseHandled = true;
159167
return true;
160168
}

0 commit comments

Comments
 (0)