question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deleting a widget (GridsterItem) leaves a gridster-preview behind

See original GitHub issue

Describe the bug

Deleting a widget (GridsterItem):

  public onDelete(item) {

    this.items.splice(this.items.indexOf(item), 1);
  }

See: dashboard.component.ts

Screen Shot 2019-06-18 at 13 18 34

Leaves a gridster-preview behind:

Screen Shot 2019-06-18 at 13 17 24

Screen Shot 2019-06-18 at 14 06 28

Demo

Firebase Hosting: Serendipity

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:12
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
tiberiuzuldcommented, Aug 26, 2019

Hello, There is already an option to delay the drag. But another simple option is to take the event on the button and call stopPropagation() And the binding in html is on mousedown instead of click since the drag is bound to mousedown also. You can see that in the demo app I do the same thing here: https://github.com/tiberiuzuld/angular-gridster2/blob/master/src/app/sections/home/home.component.ts#L92

6reactions
eesteincommented, Jul 26, 2019

Alright, so I’ve figured it out. When I clicked on my custom delete button the mousedown on gridster item was triggered, and thereafter the drag process started. Since on that process, I (and I’m assuming all of you as well) would correctly remove the item from the array of items, gridster didn’t know the process was finished, because it was never “released”.

The solution was pretty simple, I remove my item from within a settimeout:

setTimeout(() => {
    this.dashboardService.removeCard(card);
}, 0);

Now it’s working properly, with no “left over” elements. Though it should be said that fixing this behavior, by maybe adding a delay to start the drag, would be the best solution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Gridster remove widget by dragging into div - Stack Overflow
I am using gridster.js and am trying to figure out a good way to set it up where I can drag one of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found