Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#52204 closed defect (bug) (reported-upstream)

Block pattern without categories make editor crash

Reported by: marreone's profile marreone Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.6
Component: Editor Keywords:
Focuses: docs Cc:


According to the documentation on [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.

Change History (3)

#1 @geheren
3 years ago

  • Component changed from General to Editor
  • Focuses docs added

#2 @skorasaurus
3 years ago

  • Resolution set to reported-upstream
  • Status changed from new to closed


Thanks for reporting. [This issue has been reported in the Gutenberg specific repository] and has been fixed in it.

It will be included in WordPress 5.7.

#3 @desrosj
3 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.