Skip to content

DataViews: Duplicating an uncategorized pattern causes a JavaScript error #66888

Closed

Description

@carolinan

Description

Originally reported on Trac: https://core.trac.wordpress.org/ticket/62367

crash when duplicating "uncategorized" patterns
condition: Fresh install of wordpress 6.7.RC4. Default 2025 theme.
Recreate problem:

Navigate "appearance" -> "editor" -> "patterns" -> "uncategorized"
select one of the three patterns -> hamburger -> "duplicate"
problem occurs
symptom: black screen - stall -- needs browser refresh to restore.
also throws javascript error;
Uncaught TypeError: e.categories is undefined ... patterns.min.js:2:6657

I am able to reproduce this problem on WordPress 6.7-RC4-59375 with any theme that registers patterns without the categories parameter.

I tested this by removing the categories parameter from a pattern in Twenty Twenty-One, which is a classic theme that registers patterns with the PHP function, and in Twenty Twenty-Four, a block theme that registers patterns by using the patterns folder.
With and without Gutenberg trunk active.

react-dom.min.js?ver=18:1 Uncaught TypeError: Cannot read properties of undefined (reading 'includes')
    at duplicate-pattern-modal.js:20:24
    at Array.filter (<anonymous>)
    at L (duplicate-pattern-modal.js:19:6)
    at U (duplicate-pattern-modal.js:48:22)
    at RenderModal (duplicate-pattern.tsx:26:27)
    at gt (react-dom.min.js?ver=18:1:45667)
    at js (react-dom.min.js?ver=18:1:120123)
    at Sl (react-dom.min.js?ver=18:1:88331)
    at kl (react-dom.min.js?ver=18:1:88259)
    at bl (react-dom.min.js?ver=18:1:88122)

The categories parameter is not required for registering a pattern, and this should not cause an error.
https://developer.wordpress.org/block-editor/reference-guides/block-api/block-patterns/#register_block_pattern

Step-by-step reproduction instructions

Navigate "appearance" -> "editor" -> "patterns" -> "uncategorized"
select one of the three patterns -> hamburger -> "duplicate"
problem occurs
symptom: black screen - stall -- needs browser refresh to restore.
also throws javascript error;
Uncaught TypeError: e.categories is undefined ... patterns.min.js:2:6657

Screenshots, screen recording, code snippet

No response

Environment info

WordPress 6.7-RC4-59375

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Activity

  1. added
    [Type] BugAn existing feature does not function as intended
    [Feature] DataViewsWork surrounding upgrading and evolving views in the site editor and beyond
    on Nov 10, 2024
  2. carolinan commented on Nov 10, 2024

    @carolinan
    ContributorAuthor

    Also reproduced on WordPress 6.6.2.

  3. moved this to 🐛 Punted to 6.7.1 in WordPress 6.7 Editor Taskson Nov 11, 2024
  4. getdave commented on Nov 11, 2024

    @getdave
    Contributor

    Thanks for reporting.

    Confidence check @ndiego for 6.7.1 🙏

  5. moved this from 🐛 Punted to 6.7.1 to ✅ Done in WordPress 6.7 Editor Taskson Nov 11, 2024
  6. moved this from ✅ Done to 🐛 Punted to 6.7.1 in WordPress 6.7 Editor Taskson Nov 12, 2024
  7. getdave commented on Nov 12, 2024

    @getdave
    Contributor

    Thanks for the quick fix! Let's get this into 6.7.1. Once WP 6.7 is launched today we can simply add the Backport to WP 6.7 Beta/RC label and it should auto-cherry pick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] DataViewsWork surrounding upgrading and evolving views in the site editor and beyond[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions