-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Post Content: Prevent infinite recursion #31455
Conversation
Size Change: -89 B (0%) Total Size: 1.31 MB
ℹ️ View Unchanged
|
return ''; | ||
} | ||
|
||
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => 'entry-content' ) ); | ||
$content = apply_filters( 'the_content', str_replace( ']]>', ']]>', $content ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be good to add a comment with a reference to where the filter is documented. It's a common pattern used in WordPress core and this file is going to be soon exposed there as well.
Completely unrelated to this PR but it should be nice to fix here since it isn't that much work.
@@ -55,19 +57,41 @@ function Placeholder() { | |||
); | |||
} | |||
|
|||
function RecursionError() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, maybe something that useNoRecursiveRenders
should also expose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, interesting. Btw, I made it a separate component because otherwise some of the ref-juggling hooks inside useBlockProps
— specifically, useScrollIntoView
— throw errors.
something that
useNoRecursiveRenders
should also expose?
This assumes apiVersion: 2
, though, because of the use of useBlockProps
. Is that acceptable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to confirm why useScrollIntoView
causes issues, maybe it was called too late, React is very strict about all the rules of hooks? I don't mind having it in its own component though. I mostly curious to confirm it isn't some sort of bug with the hook.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one, I haven't tested yet but code looks good 👍🏻
I believe |
In fact, you can see the same issue when you go to the page where you can edit a given Reusable block or Template Part block. I would have to find my comment where I describe the same issue. Update: my related comment presenting exactly the same issue for Template Part block: |
This seems acceptable to me, no? I agree with Grzegorz that this experience will always be a little awkward, but the crucial thing is that we stop the recursion. |
Yes, it is fine to move forward. Fixing the issue might require changes to how the list of blocks is handled for those special cases. @ellatrix is looking into some slightly related changes to how |
Fixes #26593.
Analogous to #28405 and #28456.
Description
How has this been tested?
Screenshots
Types of changes
Checklist:
*.native.js
files for terms that need renaming or removal).