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
fix: nested grids #1980
Closed
Closed
fix: nested grids #1980
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,8 @@ | |
|
||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
import { GridStackDDI } from './gridstack-ddi'; | ||
import { GridItemHTMLElement, GridStackNode, GridStackElement, DDUIData, DDDragInOpt, GridStackPosition } from './types'; | ||
import { GridStack, MousePosition } from './gridstack'; | ||
import { GridItemHTMLElement, GridStackNode, GridStackElement, DDUIData, DDDragInOpt, GridStackPosition, GridStackOptions } from './types'; | ||
import { GridStack, GridStackWidget, MousePosition } from './gridstack'; | ||
import { Utils } from './utils'; | ||
|
||
/** Drag&Drop drop options */ | ||
|
@@ -131,8 +131,6 @@ GridStack.prototype._setupAcceptWidget = function(this: GridStack): GridStack { | |
// set accept drop to true on ourself (which we ignore) so we don't get "can't drop" icon in HTML5 mode while moving | ||
if (node?.grid === this) return true; | ||
if (!this.opts.acceptWidgets) return false; | ||
// prevent deeper nesting until rest of 992 can be fixed | ||
if (node?.subGrid) return false; | ||
// check for accept method or class matching | ||
let canAccept = true; | ||
if (typeof this.opts.acceptWidgets === 'function') { | ||
|
@@ -267,16 +265,24 @@ GridStack.prototype._setupAcceptWidget = function(this: GridStack): GridStack { | |
GridStackDD.get().remove(el); | ||
} | ||
if (!wasAdded) return false; | ||
|
||
el.gridstackNode = node; | ||
node.el = el; | ||
// @ts-ignore | ||
Utils.copyPos(node, this._readAttr(this.placeholder)); // placeholder values as moving VERY fast can throw things off #1578 | ||
Utils.removePositioningStyles(el);// @ts-ignore | ||
// placeholder values as moving VERY fast can throw things off #1578 | ||
Utils.copyPos(node, this._readAttr(this.placeholder)); | ||
Utils.removePositioningStyles(el); | ||
this._writeAttr(el, node); | ||
this.el.appendChild(el);// @ts-ignore | ||
this.el.appendChild(el); | ||
this._updateContainerHeight(); | ||
this.engine.addedNodes.push(node);// @ts-ignore | ||
this._triggerAddEvent();// @ts-ignore | ||
|
||
const subgrid = node.subGrid as GridStack; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that looks a lot better. Just add this comment |
||
if (subgrid) { | ||
subgrid._updateStyles(true, subgrid.getRow()); | ||
} | ||
|
||
this.engine.addedNodes.push(node); | ||
|
||
this._triggerAddEvent(); | ||
this._triggerChangeEvent(); | ||
|
||
this.engine.endUpdate(); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are those CSS changes necessary ? I though the blended background was enough to distinguish the nesting - adding border will mess the padding and create unnecessary scroll content/sizing issues...
I didn't pull in your changes to check.