Open Tropicalista opened 2 months ago
@Tropicalista, can you provide code for a simple block that mimics the Patterns (Reusable) block? The issue might be with it.
Help us move this issue forward. This issue is being marked stale since it has no activity after 15 days of requesting more information. Please add info requested so we can help move the issue forward. Note: The triage policy is to close stale issues that need more info and no response after 2 weeks.
This is solved with Gutenberg 19.4.0
This come out again with wp 6.7 RC 1.
The above error occurred in the <ForwardRef(PostTitle)> component:
at PostTitle (http://localhost:10005/wp-includes/js/dist/editor.js?ver=f84c1fcefdc6332efbd1:20825:53)
at div
at div
at WritingFlow (http://localhost:10005/wp-includes/js/dist/block-editor.js?ver=ba158b1bfcaf2bda05b0:43957:3)
at div
at BlockTools (http://localhost:10005/wp-includes/js/dist/block-editor.js?ver=ba158b1bfcaf2bda05b0:58576:3)
at ExperimentalBlockCanvas (http://localhost:10005/wp-includes/js/dist/block-editor.js?ver=ba158b1bfcaf2bda05b0:59136:3)
at div
at Resizable (http://localhost:10005/wp-includes/js/dist/components.js?ver=75e0765bccdbc4da087e:62986:28)
at UnforwardedResizableBox (http://localhost:10005/wp-includes/js/dist/components.js?ver=75e0765bccdbc4da087e:64031:3)
at ResizableEditor (http://localhost:10005/wp-includes/js/dist/editor.js?ver=f84c1fcefdc6332efbd1:27050:3)
at div
at VisualEditor (http://localhost:10005/wp-includes/js/dist/editor.js?ver=f84c1fcefdc6332efbd1:27266:3)
at SlotComponent (http://localhost:10005/wp-includes/js/dist/components.js?ver=75e0765bccdbc4da087e:33416:5)
at Slot
at UnforwardedSlot (http://localhost:10005/wp-includes/js/dist/components.js?ver=75e0765bccdbc4da087e:33976:5)
at EditCanvasContainerSlotSlot
at div
at http://localhost:10005/wp-includes/js/dist/editor.js?ver=f84c1fcefdc6332efbd1:9868:3
at div
at div
at div
at InterfaceSkeleton (http://localhost:10005/wp-includes/js/dist/editor.js?ver=f84c1fcefdc6332efbd1:9958:3)
at EditorInterface (http://localhost:10005/wp-includes/js/dist/editor.js?ver=f84c1fcefdc6332efbd1:27596:3)
at BlockRefsProvider (http://localhost:10005/wp-includes/js/dist/block-editor.js?ver=ba158b1bfcaf2bda05b0:27719:3)
at Provider (http://localhost:10005/wp-includes/js/dist/components.js?ver=75e0765bccdbc4da087e:33991:3)
at http://localhost:10005/wp-includes/js/dist/block-editor.js?ver=ba158b1bfcaf2bda05b0:36995:5
at http://localhost:10005/wp-includes/js/dist/block-editor.js?ver=ba158b1bfcaf2bda05b0:36539:3
at BlockContextProvider (http://localhost:10005/wp-includes/js/dist/block-editor.js?ver=ba158b1bfcaf2bda05b0:37058:3)
at EntityProvider (http://localhost:10005/wp-includes/js/dist/core-data.js?ver=c8526dfd5ea638e51031:6994:3)
at EntityProvider (http://localhost:10005/wp-includes/js/dist/core-data.js?ver=c8526dfd5ea638e51031:6994:3)
at http://localhost:10005/wp-includes/js/dist/editor.js?ver=f84c1fcefdc6332efbd1:24561:3
at http://localhost:10005/wp-includes/js/dist/editor.js?ver=f84c1fcefdc6332efbd1:21964:3
at Editor (http://localhost:10005/wp-includes/js/dist/editor.js?ver=f84c1fcefdc6332efbd1:29324:3)
at div
at ErrorBoundary (http://localhost:10005/wp-includes/js/dist/editor.js?ver=f84c1fcefdc6332efbd1:11688:5)
at SlotFillProvider (http://localhost:10005/wp-includes/js/dist/components.js?ver=75e0765bccdbc4da087e:33829:3)
at provider_SlotFillProvider (http://localhost:10005/wp-includes/js/dist/components.js?ver=75e0765bccdbc4da087e:33927:3)
at Provider (http://localhost:10005/wp-includes/js/dist/components.js?ver=75e0765bccdbc4da087e:33991:3)
at Layout (http://localhost:10005/wp-includes/js/dist/edit-post.js?ver=9567d2bb2ad838a6bbda:3116:11)
React will try to recreate this component tree from scratch using the error boundary you provided, ErrorBoundary.
@Tropicalista, the issue is fixed in Gutenberg 19.4 but not in WP 6.7 RC1. Is that correct?
Yes it's correct. Can this be related?
I tested it with the following steps and I think I was able to reproduce it.
release/19.5
Interestingly, this issue does not occur in the release/19.5
branch of Gutenberg, but the editor crashes in the trunk (86a3bc9bb3). So, the result is as follows:
release/19.5
branchIt is still unclear whether this is a plugin issue or a Gutenberg issue.
https://github.com/user-attachments/assets/9c430da1-4809-4763-904d-b8a6ee01fa69
@Tropicalista I tested this issue again with minimal code and am unable to reproduce the issue in 6.7 RC1.
The following code creates a custom post called "Book" and tests navigating to the post via a block.
https://github.com/user-attachments/assets/07827568-23f1-4e90-bb86-5e9f72b83aa8
Is your code attempting to access a variable or element that may be undefined?
Moving this back to "In Discussion" on the 6.7 project board for the time being.
I think I found the problem.
This code works. But of course it will not display the children
export default function ReusableBlockEdit( {
attributes: { ref },
clientId,
name,
setAttributes,
} ) {
const [ isModalOpen, setModalOpen ] = useState( false );
const [ isDisabled, setIsDisabled ] = useState( true );
const [ titleTemp, createTitle ] = useState( '' );
const { onNavigateToEntityRecord } = useSelect(
( select ) => {
const {
getSettings,
} = select( blockEditorStore );
// For editing link to the site editor if the theme and user permissions support it.
return {
onNavigateToEntityRecord:
getSettings().onNavigateToEntityRecord,
};
},
[ clientId, ref ]
);
const handleEditOriginal = () => {
onNavigateToEntityRecord( {
postId: ref,
postType: 'formello_form',
} );
};
const blockProps = useBlockProps();
const { children, ...innerBlocksProps } = useInnerBlocksProps( blockProps );
return (
<div { ...innerBlocksProps }>
<BlockControls>
<ToolbarGroup>
<ToolbarButton onClick={ handleEditOriginal }>
{ __( 'Edit form', 'formello' ) }
</ToolbarButton>
</ToolbarGroup>
</BlockControls>
{ children }
</div>
);
}
IT will crash if I change the code to something like this:
const [ blocks, onInput, onChange ] = useEntityBlockEditor(
'postType',
'formello_form',
{ id: ref }
);
const innerBlocksProps = useInnerBlocksProps( blockProps, {
value: blocks,
onInput,
onChange,
allowedBlocks: [ 'formello/form' ],
renderAppender: blocks?.length
? undefined
: InnerBlocks.ButtonBlockAppender,
} );
Do you have any idea of what should I do to prevent this error? Is it a bug or is my code worng?
I'm still not sure if this is a problem with Gutenberg itself.
@Tropicalista
SCRIPT_DEBUG
and tell us the error you get?@t-hamano I have uploaded a demo repo that you can test here:
Link to repo: https://github.com/Tropicalista/navigate-to-entity/tree/master
To be clear, if I use the code you shared before, without a children block, it works.
The code of the block is very simple and you can see it here: https://github.com/Tropicalista/navigate-to-entity/blob/master/src/edit.js
Description
I have a custom post type which I wanna use as a pattern.
If I try something like this, the editor crashes.
The error is:
Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
No response
Environment info
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.