grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

BUG: BlocksView rendering is being called twice

Open mig8447 opened this issue 5 years ago • 3 comments

https://github.com/artf/grapesjs/blob/b199083f6a6128ecff41d20865493294f71fe0a1/src/block_manager/view/BlocksView.js#L186

The Block Manager is looking for a rendered property in the model to tell if the view did render already or not but this method doesn't set said property and therefore this function is called twice, once by the resetevent and once ny the Block Manager. A line containing:

this.rendered = true;

Should be added for this to stop happening

mig8447 avatar Feb 20 '21 17:02 mig8447

Yeah, makes sense, thanks

artf avatar Mar 03 '21 20:03 artf

https://github.com/artf/grapesjs/blob/b199083f6a6128ecff41d20865493294f71fe0a1/src/block_manager/view/BlocksView.js#L186

The Block Manager is looking for a rendered property in the model to tell if the view did render already or not but this method doesn't set said property and therefore this function is called twice, once by the resetevent and once ny the Block Manager. A line containing:

this.rendered = true;

Should be added for this to stop happening

@mig8447 hi! I am facing the similar issue. The function from script of component is getting called twice. Can you please explain where should I need to add 'this.rendered = true' ?

RutujaBadbe avatar Mar 10 '21 12:03 RutujaBadbe

@RutujaBadbe This is the exact change you need: https://github.com/artf/grapesjs/commit/640661b0a44e5e2857b615559c1db27da3e17a6c

mig8447 avatar Mar 11 '21 18:03 mig8447