ember-mobiledoc-editor
ember-mobiledoc-editor copied to clipboard
Fixed ember-wormhole bug caused when cards are Edited, Saved and then…
… Re-Edited.
-Issue occurs because the card add/remove hooks will fire overtop of each other, leaving a componentCard entry that shouldn't be there. Wormhole then tries to access the documentId which doesn't exist resulting in an exception.
@jamesjhedley it seems really bad if cards are being rendered and then un-rendered before the afterRender
queue fires. That means a lot of work has been done to render cards that were never visible to the user.
Can you describe the use case more or provide a reproduction?
@mixonic It happens for us when we add a card to the editor at which point the addCard function is executed.
<button class="wysiwyg_html" {{action editor.addCardInEditMode 'shared-embed-card'}}/>
The editor for the card opens and i enter a value and hit save. Which calls saveCard and passes the payload.
The display mode UI for the card then shows, i hit edit to go back into edit mode and hit save and then i get the wormhole exception and the editor completely dies.
I'm able to consistently reproduce the issue using those steps. It's possible it happens in other scenarios as well. Can you reproduce it on your side?
@jamesjhedley its going to be difficult to reproduce the specific case you're seeing.
It sounds like you have a mobiledoc that has been altered, and so the on-change action is dispatched. Then something outside the mobiledoc component perhaps creates a new object reference which causes a re-render.
Mobiledoc-kit protects against this case, as far as I know. However your case sounds like it might be a similar permutation.
I'd prefer to fix the root issue here, or see if we can improve Mobiledoc-kit's error messaging when people run into something like this. The patch in this PR is an ok stop-gap, but it papers over a significant performance issue and adds some unexpected behavior to the system.