[wp-trac] [WordPress Trac] #52204: Block pattern without categories make editor crash

WordPress Trac noreply at wordpress.org
Sun Jan 3 01:56:06 UTC 2021


#52204: Block pattern without categories make editor crash
--------------------------+-----------------------------
 Reporter:  marreone      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  5.6
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 According to the documentation on [block
 patterns|https://developer.wordpress.org/block-editor/developers/block-api
 /block-patterns/] the attribute "categories" is optional. But when I
 register a custom block pattern without the categories attribute the
 editor crashes when i edit a post or page and:
 1. Click the "+" to add a block
 2. Chose "Browse all"
 3. Chose "Patterns" in the pane to the left (to the left on desktop,
 fullscreen on mobile)

 The error I then get is:

 {{{
 TypeError: Cannot read property 'includes' of undefined
     at http://head/wp-includes/js/dist/block-
 editor.min.js?ver=5f6a75cdc59f1a900e9d4bcfb43bddba:12:207713
     at Array.some (<anonymous>)
     at http://head/wp-includes/js/dist/block-
 editor.min.js?ver=5f6a75cdc59f1a900e9d4bcfb43bddba:12:207675
     at Array.filter (<anonymous>)
     at http://head/wp-includes/js/dist/block-
 editor.min.js?ver=5f6a75cdc59f1a900e9d4bcfb43bddba:12:207646
     at Object.useMemo (http://head/wp-includes/js/dist/vendor/react-
 dom.min.js?ver=16.13.1:216:441)
     at d.useMemo (http://head/wp-
 includes/js/dist/vendor/react.min.js?ver=16.13.1:32:231)
     at Vl (http://head/wp-includes/js/dist/block-
 editor.min.js?ver=5f6a75cdc59f1a900e9d4bcfb43bddba:12:207624)
     at we (http://head/wp-includes/js/dist/vendor/react-
 dom.min.js?ver=16.13.1:84:293)
     at zj (http://head/wp-includes/js/dist/vendor/react-
 dom.min.js?ver=16.13.1:226:496)
 }}}

 It could be that this is working as intended and that the documentation is
 wrong (that categories should be marked as required), but supplying an
 empty array for categories works fine (resulting in the block pattern
 appearing under the category "Uncategorized") and hence I guess omitting
 the categories attribute should work as well. But I may be wrong.

 I also tested the steps above in a vanilla WP 5.6 with themes Twenty
 Twenty One and Twenty Twenty by removing categories attribute from wp-
 includes/block-patterns/text-two-columns-with-images.php to ensure no
 custom code or plugins were causing this error.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/52204>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list