WordPress.org

Make WordPress Core

Opened 9 months ago

Closed 7 months ago

Last modified 6 months ago

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

Block pattern without categories make editor crash

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

Description

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.

Change History (3)

#1 @geheren
9 months ago

  • Component changed from General to Editor
  • Focuses docs added

#2 @skorasaurus
7 months ago

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

Hi,

Thanks for reporting. [This issue has been reported in the Gutenberg specific repository]https://github.com/WordPress/gutenberg/issues/27249 and has been fixed in it.

It will be included in WordPress 5.7.

#3 @desrosj
6 months ago

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