Ensure the attributes.content
param exists before using it
#220
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.
Description of the Change
As described on WordPress.org, with the latest update, some blocks are crashing. I installed the plugin mentioned (Spectra Blocks) and when using the blocks that plugin adds (like Call to Action) I was able to reproduce the reported issue.
The problem stems from the work done in #207, in particular this line: https://github.com/10up/insert-special-characters/pull/207/files#diff-bfe9874d239014961b1ae4e89875a6155667db834a410aaaa2ebe3cf89820556R117. It seems some blocks don't have the
attributes.content
set, so when we try and access that, it throws a JS error and prevents the block from working.I've fixed that in this PR but ensuring that data exists before we try to use it and that does seem to fix the reported issue. I'm not sure if it's the best approach though or if there's a better way to handle this. In addition, while this prevents the block from breaking, the toolbar is still shown but doesn't seem to work. Not sure if there's a way to make the toolbar work in this instance or if there's a way to remove the toolbar all together? Not sure if this is an instance where we could be doing something different or if it's an issue with how these custom blocks are built, since they don't seem to have the standard
content
attribute.How to test the Change
Changelog Entry
Credits
Props @dkotter
Checklist: