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

BUG: Destroying and re-initializing produces "Cannot read properties of undefined (reading 'get')" #4940

Closed
2 tasks done
mani-rai opened this issue Feb 21, 2023 · 1 comment

Comments

@mani-rai
Copy link

GrapesJS version

  • I confirm to use the latest version of GrapesJS

What browser are you using?

Google Chrome Version 110.0.5481.100 (Official Build) (64-bit)

Reproducible demo link

https://stackblitz.com/edit/js-3urscf?file=index.html,index.js

Describe the bug

How to reproduce the bug?

  1. Initialize the editor
  2. Destroy the editor
  3. Initialize the editor again

What is the expected behavior?
The code used is just a starter code from the official doc. It should be re-initialized without any problem.

What is the current behavior?
Multiple errors are show in console.

TypeError: Cannot read properties of undefined (reading 'get')
at o.runDefault (Editor.ts:874:28)
at n.updateOffset (FrameWrapView.ts:89:8)
at _e (_executeBound.js:8:65)
at n.eval (bind.js:10:12)
at n.eval (restArguments.js:16:27)
at l (debounce.js:17:37)

Another:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'forEach')
at s (Editor.ts:317:20)
at o.eval (Editor.ts:336:9)
at eval (grapes.min.js:2:911116)
at Object.eval [as next] (grapes.min.js:2:911221)
at eval (grapes.min.js:2:910096)
at new Promise ()
at nh (grapes.min.js:2:909838)
at eval (Editor.ts:326:18)

If is necessary to execute some code in order to reproduce the bug, paste it here below:

// Not Necessary

Code of Conduct

  • I agree to follow this project's Code of Conduct
@artf
Copy link
Member

artf commented Feb 23, 2023

Yeah, the editor instance is not expected to be destroyed immediately due to some deferred async functions (eg. for the StorageManager) but that can be fixed.
For now you can overcome the issue by doing something like this:

setTimeout(() => {
  editor.destroy();
  ...

@artf artf closed this as completed in 401f97d Feb 23, 2023
artf added a commit that referenced this issue May 2, 2023
* fix for when no implicit type (#4903)

fix for no implicit type

Co-authored-by: Sergio Wilson <[email protected]>

* Fix broken links in the docs (#4914)

* moved repo from artf to GrapesJS 1st pass

* exceptions

* Fix typing of trigger to include `args` (#4910)

* Fix typing of trigger to include `args`

* Update index.d.ts

I don't even know how this got here haha

* Remove ComponentLabelView hotfix for the tagName

* TS Types: Extends the type of property that scripts/styles can takes (#4924)

chore(types): Extends the type of property that scripts and styles can take

* Convert Trait test into TS (#4899)

Co-authored-by: Artur Arseniev <[email protected]>

* Clear deferred stuff on editor destroy. Fixes #4940

* Remove unused stuff from Editor

* Add new `noCustom` option to `Component.getName()`

* Up jsdoc

* Add `rename` method to SelectorManager

* Use rename in ClassTagView

* Add duplicateSelected

* Update Components.md (#4952)

Grammer correction for Component Recognition and Component Type Stack section

* Fix typos

* docs: Fix a few typos (#4957)

There are small typos in:
- docs/api/selector.md
- docs/api/storage_manager.md
- docs/modules/Blocks.md
- docs/modules/Components.md
- docs/modules/I18n.md
- docs/modules/Storage.md
- docs/modules/Traits.md

Fixes:
- Should read `argument` rather than `argumnet`.
- Should read `with` rather than `wiht`.
- Should read `redundant` rather than `redundent`.
- Should read `propagation` rather than `propogation`.
- Should read `performances` rather than `perfomances`.
- Should read `implementation` rather than `implemenation`.
- Should read `contributors` rather than `contributos`.
- Should read `attached` rather than `attacched`.

Signed-off-by: Tim Gates <[email protected]>

* Fix broken links in the docs (#4963)

* docs: Fix broken link of Storage

* docs: Fix broken link of Blocks

* docs: Fix broken link of Style-manager

* docs: Fix broken link of Commands

* docs: Fix broken link of Assets

---------

Co-authored-by: Artur Arseniev <[email protected]>

* Fix link in Assets doc

* Fix slider in StyleManager. Closes #4965

* Fix checkbox trait values on undo/redo. Closes #4972

* Add `fetchOptions` to AssetManager configs

* Fix sorter placeholder with grid elements. Closes #4991

* Module cleanup (#4985)

* module cleanup

* Fix ??

---------

Co-authored-by: Artur Arseniev <[email protected]>

* improve typing (#5010)

* Add options to ExportTemplate command

* Fix showOffsetsSelected. Closes #4998

* fix: resolved bug with top/left being sticky when resizing from l/t side

* Prevent top/left update if not in standard drag mode

* Up Resizer dim values

* Up key for the partial update

* Build

* Up docs

* Add TS

* Remove previous index.d.ts

* Update README links

* Add getValue/setValue to Trait

* Improve TS for `Components.addType`. Closes #5053

---------

Signed-off-by: Tim Gates <[email protected]>
Co-authored-by: Sergio Wilson <[email protected]>
Co-authored-by: Sergio Wilson <[email protected]>
Co-authored-by: Alex Hoyau <[email protected]>
Co-authored-by: Zach Sadler <[email protected]>
Co-authored-by: Esteban Gonzalez <[email protected]>
Co-authored-by: Alex Ritter <[email protected]>
Co-authored-by: jacobisknight <[email protected]>
Co-authored-by: Tim Gates <[email protected]>
Co-authored-by: Himansh <[email protected]>
Co-authored-by: Singwai Chan <[email protected]>
Co-authored-by: Paul Rill <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants