RichText: don't apply input transform when there's no onReplace - #80978
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: +9 B (0%) Total Size: 7.76 MB 📦 View Changed
|
aduth
left a comment
There was a problem hiding this comment.
This makes sense 👍 Though my static typing brain wonders what the expected shape of onReplace should be, and if it's reasonable to expect it should always be a function that locking blocks could pass as a noop rather than as undefined.
|
@aduth, the RichText relies on a similar P.S. I think we had similar conversation on another Jarda's PRs 😄 |
By not passing |
Fixes a crash when a
RichTextfield wants to apply aninputtransform, but there is noonReplacehandler that would execute the transform, i.e., replace the current block with another one.Steps to reproduce:
core/pullquoteblock that has a field with text, but no ability to contain inner blocks. Or a lockedcore/paragraph, with locked removal.---inside. This would normally convert the block to a separator, but in these cases the new block can't be created.The fix is to guard the transform logic on
onReplaceand don't attempt transforms. TheinputRulefunction in the same file already guards ononReplacewhen handling theprefixtransforms.This bug was reported in WP.com automated JS error reporting.