Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restored grid option.handle check #2210

Merged
merged 1 commit into from
Feb 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Change log

## 7.2.3-dev (TBD)
* fix [#2206](https://github.com/gridstack/gridstack.js/issues/2206) `load()` with collision fix
* fix [#2210](https://github.com/gridstack/gridstack.js/pull/2210) restored checking for grid option.handle draggable area

## 7.2.3 (2023-02-02)
* fix `addWidget()` to handle passing just {el} which was needed for Angular HMTL template demo
Expand Down
15 changes: 7 additions & 8 deletions src/dd-draggable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
this.el = el;
this.option = option;
// get the element that is actually supposed to be dragged by
let className = option.handle.substring(1);
this.dragEl = el.classList.contains(className) ? el : el.querySelector(option.handle) || el;
let handleName = option.handle.substring(1);
this.dragEl = el.classList.contains(handleName) ? el : el.querySelector(option.handle) || el;
// create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)
this._mouseDown = this._mouseDown.bind(this);
this._mouseMove = this._mouseMove.bind(this);
Expand Down Expand Up @@ -138,12 +138,11 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt

// make sure we are clicking on a drag handle or child of it...
// 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)
//
// REMOVE: why would we get the event if it wasn't for us or child ?
// let className = this.option.handle.substring(1);
// let el = e.target as HTMLElement;
// while (el && !el.classList.contains(className)) { el = el.parentElement; }
// if (!el) return;
let className = this.option.handle.substring(1);
let el = e.target as HTMLElement;
while (el && !el.classList.contains(className)) { el = el.parentElement; }
if (!el) return;

this.mouseDownEvent = e;
delete this.dragging;
delete DDManager.dragElement;
Expand Down