Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Change log
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*

- [9.2.1-dev (TBD)](#921-dev-tbd)
- [9.2.1 (2023-09-20)](#921-2023-09-20)
- [9.2.0 (2023-09-10)](#920-2023-09-10)
- [9.1.1 (2023-09-06)](#911-2023-09-06)
Expand Down Expand Up @@ -99,6 +100,9 @@ Change log

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

## 9.2.1-dev (TBD)
* fix - sub-grid styles now look for immediate correct parent, not any depth above.

## 9.2.1 (2023-09-20)
* fix _updateContainerHeight() to use height rather than min-height again (apart for nested grids which need it) and partial getComputedStyle CSS minHeight support

Expand Down
3 changes: 2 additions & 1 deletion src/gridstack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ export class GridStack {
}

// check if we're been nested, and if so update our style and keep pointer around (used during save)
let parentGridItem = (Utils.closestUpByClass(this.el, gridDefaults.itemClass) as GridItemHTMLElement)?.gridstackNode;
const grandParent: GridItemHTMLElement = this.el.parentElement?.parentElement;
let parentGridItem = grandParent?.classList.contains(gridDefaults.itemClass) ? grandParent.gridstackNode : undefined;
if (parentGridItem) {
parentGridItem.subGrid = this;
this.parentGridItem = parentGridItem;
Expand Down
14 changes: 7 additions & 7 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,13 @@ export class Utils {
}

/** return the closest parent (or itself) matching the given class */
static closestUpByClass(el: HTMLElement, name: string): HTMLElement {
while (el) {
if (el.classList.contains(name)) return el;
el = el.parentElement
}
return null;
}
// static closestUpByClass(el: HTMLElement, name: string): HTMLElement {
// while (el) {
// if (el.classList.contains(name)) return el;
// el = el.parentElement
// }
// return null;
// }

/** delay calling the given function for given delay, preventing new calls from happening while waiting */
static throttle(func: () => void, delay: number): () => void {
Expand Down