Skip to content

Commit a80857a

Browse files
authored
Merge pull request #2063 from adumesny/v6
Can't enter text in textarea
2 parents 13b82d5 + b6e5b39 commit a80857a

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

demo/serialization.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ <h1>Serialization demo</h1>
3030
});
3131

3232
grid.on('added removed change', function(e, items) {
33+
if (!items) return;
3334
let str = '';
3435
items.forEach(function(item) { str += ' (x,y)=' + item.x + ',' + item.y; });
3536
console.log(e.type + ' ' + items.length + ' items:' + str );
3637
});
3738

3839
let serializedData = [
3940
{x: 0, y: 0, w: 2, h: 2, id: '0'},
40-
{x: 3, y: 1, h: 2, id: '1', content: "<button onclick=\"alert('clicked!')\">Press me</button>"},
41+
{x: 3, y: 1, h: 2, id: '1', content: "<button onclick=\"alert('clicked!')\">Press me</button><div>text area</div><div><textarea></textarea></div><div>Input Field</div><input type='text'>"},
4142
{x: 4, y: 1, id: '2'},
4243
{x: 2, y: 3, w: 3, id: '3'},
4344
{x: 1, y: 3, id: '4'}

doc/CHANGES.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ Change log
7373
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
7474

7575
## 6.0.2-dev (TBD)
76-
* fixed [#2055](https://github.com/gridstack/gridstack.js/issues/2055) maxRow=1 resize outside
76+
* fixed [#2055](https://github.com/gridstack/gridstack.js/issues/2055) maxRow=1 resize outside (broke in 6.0.1)
77+
* fixed [#2054](https://github.com/gridstack/gridstack.js/issues/2054) Can't enter text in textarea/input (broke in v6)
7778

7879
## 6.0.2 (2022-09-23)
7980
* fixed [#2034](https://github.com/gridstack/gridstack.js/issues/2034) `removeWidget()` breaking resize handle feedback

src/dd-draggable.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,19 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
125125
if (DDManager.mouseHandled) return;
126126
if (e.button !== 0) return true; // only left click
127127

128+
// make sure we are not clicking on known object that handles mouseDown (TODO: make this extensible ?) #2054
129+
const skipMouseDown = ['input', 'textarea', 'button', 'select', 'option'];
130+
const name = (e.target as HTMLElement).nodeName.toLowerCase();
131+
if (skipMouseDown.find(skip => skip === name)) return true;
132+
128133
// make sure we are clicking on a drag handle or child of it...
129134
// 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)
130-
let className = this.option.handle.substring(1);
131-
let el = e.target as HTMLElement;
132-
while (el && !el.classList.contains(className)) { el = el.parentElement; }
133-
if (!el) return;
135+
//
136+
// REMOVE: why would we get the event if it wasn't for us or child ?
137+
// let className = this.option.handle.substring(1);
138+
// let el = e.target as HTMLElement;
139+
// while (el && !el.classList.contains(className)) { el = el.parentElement; }
140+
// if (!el) return;
134141
this.mouseDownEvent = e;
135142
delete this.dragging;
136143
delete DDManager.dragElement;
@@ -184,7 +191,7 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
184191
}
185192
this.triggerEvent('dragstart', ev);
186193
}
187-
e.preventDefault();
194+
e.preventDefault(); // needed otherwise we get text sweep text selection as we drag around
188195
return true;
189196
}
190197

0 commit comments

Comments
 (0)