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

dynamically created nested grid disappeared when dragging out (doesn't restore) #2948

Open
jujingyi520 opened this issue Feb 17, 2025 · 8 comments

Comments

@jujingyi520
Copy link

Watch the video https://gridstackjs.com/demo/nested_advanced.html

video_10086.mp4
@adumesny
Copy link
Member

yep, I see that...

@jujingyi520
Copy link
Author

May I ask when you would like to fix this BUG ^ - ^

@adumesny
Copy link
Member

adumesny commented Feb 17, 2025

not high on my priority as I don't use nested grid at work, let alone dynamically nested grids. You can donate if you want it fixed sooner - reach out on slack. thanks.

@adumesny adumesny changed the title nested grid disappeared without a trace dynamically created nested grid disappeared when dragging out (doesn't restore) Feb 17, 2025
@adumesny adumesny reopened this Feb 18, 2025
@jujingyi520
Copy link
Author

The function "removeAsSubGrid" adds a judgment to ensure that it is not eliminated

  removeAsSubGrid(nodeThatRemoved) {
    if (!nodeThatRemoved._event) {
      return
    }
    const pGrid = this.parentGridNode?.grid
    if (!pGrid) return
    pGrid.batchUpdate()
    pGrid.removeWidget(this.parentGridNode.el, true, true)
    this.engine.nodes.forEach((n) => {
      // migrate any children over and offsetting by our location
      n.x += this.parentGridNode.x
      n.y += this.parentGridNode.y
      pGrid.makeWidget(n.el, n)
    })
    pGrid.batchUpdate(false)
    if (this.parentGridNode) delete this.parentGridNode.subGrid
    delete this.parentGridNode
    // create an artificial event for the original grid now that this one is gone (got a leave, but won't get enter)
    if (nodeThatRemoved) {
      window.setTimeout(() => Utils.simulateMouseEvent(nodeThatRemoved._event, "mouseenter", pGrid.el), 0)
    }
  }

@adumesny
Copy link
Member

adumesny commented Feb 24, 2025

why are you closing this when it is not fixed in the lib ? are yu saying the first 2 lines fixes the issue now ?

@adumesny adumesny reopened this Feb 24, 2025
@jujingyi520
Copy link
Author

Yes.

@jujingyi520
Copy link
Author

Are you still working after 6:00 at night? It is half past ten Beijing time. 😃

@adumesny
Copy link
Member

you can submit a code review and get credit with the fix. thanks.
and I'm always working :) (weekend for this lib. Sunday night right now)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants