Fixing bug thats preventing snippets from rerendering on run button click #466
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I encountered a bug where snippets wouldn't get re-rendered when clicking the run snippets button and was always one change behind. I could only force the snippet to update by swapping between editor views.
video_1280.mp4
I found that this was caused due to how we decided to update the results in snippet-view.ts within the update function.
Here's the flow:
if (content && (metaChanged || this.resultContainer.innerHTML === ""))and because the snippet meta data has updated we reinitialize the Iframe for the snippets result but reinject our contentNode html into the iframe. The content node is what we get back from the renderer and only gets set on button click, we therefore are not updating the actual contents of what is displayed to the user.
Describe your changes
I address this issue by instead of comparing if the snippet meta data has changed I compare the contentNode's innerHtml to a snapshots. This makes it so that the snippet results are only updated on run button click.