Skip to content

Commit fce34a0

Browse files
authored
Merge pull request #2379 from adumesny/master
decline feat cleanup
2 parents 756067a + b541c6e commit fce34a0

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

doc/CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Change log
55
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
66
**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*
77

8+
- [8.3.0-dev (TBD)](#830-dev-tbd)
89
- [8.3.0 (2023-06-13)](#830-2023-06-13)
910
- [8.2.3 (2023-06-11)](#823-2023-06-11)
1011
- [8.2.1 (2023-05-26)](#821-2023-05-26)
@@ -91,6 +92,9 @@ Change log
9192

9293
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
9394

95+
## 8.3.0-dev (TBD)
96+
* feat [#2378](https://github.com/gridstack/gridstack.js/pull/2378) attribute `DDRemoveOpt.decline` to deny the removal of a specific class.
97+
9498
## 8.3.0 (2023-06-13)
9599
* feat [#2358](https://github.com/gridstack/gridstack.js/issues/2358) column(N, 'list'|'compact'|...) resizing now support reflowing content as list
96100

doc/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ gridstack.js API
7070
## Grid Options
7171

7272
- `acceptWidgets` - Accept widgets dragged from other grids or from outside (default: `false`). Can be:
73-
* `true` will accept HTML element having `'.grid-stack-item'` as class attribute, else `false`
73+
* `true` will accept HTML element having `'grid-stack-item'` as class attribute, else `false`
7474
* string for explicit class name to accept instead
7575
* `function (el: Element): boolean` function called before an item will be accepted when entering a grid. the function will be passed the item being dragged, and should return true | false. See [example](https://github.com/gridstack/gridstack.js/blob/master/demo/two.html#L62)
7676
- `alwaysShowResizeHandle` - possible values (default: `mobile`) - does not apply to non-resizable widgets

src/dd-droppable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export class DDDroppable extends DDBaseImplement implements HTMLElementExtendOpt
156156
protected _setupAccept(): DDDroppable {
157157
if (!this.option.accept) return this;
158158
if (typeof this.option.accept === 'string') {
159-
this.accept = (el: HTMLElement) => el.matches(this.option.accept as string);
159+
this.accept = (el: HTMLElement) => el.classList.contains(this.option.accept as string) || el.matches(this.option.accept as string);
160160
} else {
161161
this.accept = this.option.accept;
162162
}

src/gridstack.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ export class GridStack {
285285
handle: (opts.handleClass ? '.' + opts.handleClass : (opts.handle ? opts.handle : '')) || gridDefaults.draggable.handle,
286286
},
287287
removableOptions: {
288-
accept: opts.itemClass ? '.' + opts.itemClass : gridDefaults.removableOptions.accept,
288+
accept: opts.itemClass || gridDefaults.removableOptions.accept,
289289
decline: gridDefaults.removableOptions.decline
290290
},
291291
};

src/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const gridDefaults: GridStackOptions = {
2525
oneColumnSize: 768,
2626
placeholderClass: 'grid-stack-placeholder',
2727
placeholderText: '',
28-
removableOptions: { accept: '.grid-stack-item' ,decline:'grid-stack-non-removable'},
28+
removableOptions: { accept: 'grid-stack-item', decline: 'grid-stack-non-removable'},
2929
resizable: { handles: 'se' },
3030
rtl: 'auto',
3131

@@ -333,8 +333,9 @@ export interface DDResizeOpt {
333333

334334
/** Drag&Drop remove options */
335335
export interface DDRemoveOpt {
336-
/** class that can be removed (default?: '.' + opts.itemClass) */
336+
/** class that can be removed (default?: opts.itemClass) */
337337
accept?: string;
338+
/** class that cannot be removed (default: 'grid-stack-non-removable') */
338339
decline?: string;
339340
}
340341

0 commit comments

Comments
 (0)