You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Uncaught TypeError: Cannot read properties of null (reading 'ownerDocument')
at apply (rich-text.js?ver=9988fecf32c29c7254e1:2492:18)
at applyRecord (rich-text.js?ver=9988fecf32c29c7254e1:3709:5)
at applyFromProps (rich-text.js?ver=9988fecf32c29c7254e1:3806:5)
at rich-text.js?ver=9988fecf32c29c7254e1:3813:7
at commitHookEffectListMount (react-dom.development.js:23184:26)
at commitLayoutEffectOnFiber (react-dom.development.js:23302:17)
at commitLayoutMountEffects_complete (react-dom.development.js:24722:9)
at commitLayoutEffects_begin (react-dom.development.js:24708:7)
at commitLayoutEffects (react-dom.development.js:24646:3)
at commitRootImpl (react-dom.development.js:26857:5)
Step-by-step reproduction instructions
Create a custom post type (ex. Doc)
Create a new post of custom post type (New doc)
Create a simple block that mimic what patterns do and add function mentioned above
Editor crashes
Screenshots, screen recording, code snippet
No response
Environment info
WP 6.6
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
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.
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.
Has anyone figured out why the bug affects a third-party plugin but not the core Patterns block?
While #66709 is a good hotfix, it's still a compromise. There should be no need to pre-select data before navigation; the editor should do it for consumers as needed (after navigation).
The reason is probably because patterns are loaded on every editor, so the post type is already there. But I agree that we need to solve the root issue. (Wait for the post type at the moment that we need it) instead of adding a fetch call in the onNavigate callback because that's probably just one way to trigger the issue.
I would be happy to close #66709. I don't like changing from sync to async in that PR and as you say the editor should be able to request the entities on demand when it navigates rather than having to have them ready in advance.
When navigating from a post of type post to a post of type book, the PostTypeSupportCheck briefly unmounts the h1 element because it internally fetches the post type for book. Only after the post type is loaded does it support title again.
The useRichText logic, namely the applyFromProps calls, get very confused when the ref is reset to null. Then a useLayoutEffect that calls applyFromProps has no element to work with.
I tried to fix this by setting didMountRef.current = false when the element unmounts. This fixes the crash, but it introduces another bug: the post title is not updated. When navigation from the "post" post to "book" post, the UI still shows the "post" title. Maybe @ellatrix can help here.
This all also explains why @getdave's fix in #66709 involves calling getPostType. By preloading the post type, it avoids unmounting the h1 in PostTypeSupportCheck.
The bug can also be fixed by wrapping all post title logic inside PostTypeSupportCheck, including the useRichText call. But that works around a bug in useRichText that would still remain there.
Activity
Mamaduka commentedon Aug 28, 2024
@Tropicalista, can you provide code for a simple block that mimics the Patterns (Reusable) block? The issue might be with it.
github-actions commentedon Sep 26, 2024
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.
Tropicalista commentedon Oct 10, 2024
This is solved with Gutenberg 19.4.0
Tropicalista commentedon Oct 23, 2024
This come out again with wp 6.7 RC 1.
Mamaduka commentedon Oct 23, 2024
@Tropicalista, the issue is fixed in Gutenberg 19.4 but not in WP 6.7 RC1. Is that correct?
Tropicalista commentedon Oct 23, 2024
Yes it's correct. Can this be related?
24 remaining items
Tropicalista commentedon Nov 7, 2024
The fix is still not working on site editor.
Simply copy the two demo from a post and try to insert in template in site editor.
Try in playground:
getdave commentedon Nov 14, 2024
@Tropicalista I don't think your Playground is using the Gutenberg PR which fixes the Issue?
Try this Playground which activates the Gutenberg PR.
Here's a screencapture of me showing it working:
Screen.Capture.on.2024-11-14.at.15-32-59.mp4
Tropicalista commentedon Nov 14, 2024
@getdave You are right.
I thought that this was merged because issue title says 6.7.
Mamaduka commentedon Nov 14, 2024
Has anyone figured out why the bug affects a third-party plugin but not the core Patterns block?
While #66709 is a good hotfix, it's still a compromise. There should be no need to pre-select data before navigation; the editor should do it for consumers as needed (after navigation).
@youknowriad, @jsnajdr, what do you think?
youknowriad commentedon Nov 14, 2024
The reason is probably because patterns are loaded on every editor, so the post type is already there. But I agree that we need to solve the root issue. (Wait for the post type at the moment that we need it) instead of adding a fetch call in the onNavigate callback because that's probably just one way to trigger the issue.
getdave commentedon Nov 18, 2024
I would be happy to close #66709. I don't like changing from sync to async in that PR and as you say the editor should be able to request the entities on demand when it navigates rather than having to have them ready in advance.
jsnajdr commentedon Nov 18, 2024
This is a bug caused by
useRichTextreturning a ref that is used on an element that is rendered conditionally. The Post Title component does this:When navigating from a post of type
postto a post of typebook, thePostTypeSupportCheckbriefly unmounts theh1element because it internally fetches the post type forbook. Only after the post type is loaded does it supporttitleagain.The
useRichTextlogic, namely theapplyFromPropscalls, get very confused when the ref is reset tonull. Then auseLayoutEffectthat callsapplyFromPropshas no element to work with.I tried to fix this by setting
didMountRef.current = falsewhen the element unmounts. This fixes the crash, but it introduces another bug: the post title is not updated. When navigation from the "post" post to "book" post, the UI still shows the "post" title. Maybe @ellatrix can help here.This all also explains why @getdave's fix in #66709 involves calling
getPostType. By preloading the post type, it avoids unmounting theh1inPostTypeSupportCheck.The bug can also be fixed by wrapping all post title logic inside
PostTypeSupportCheck, including theuseRichTextcall. But that works around a bug inuseRichTextthat would still remain there.cbravobernal commentedon Nov 22, 2024
Cherry-picked to 6.7 branch for a 6.7.2 release.