Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
4 of 6 tasks
carolinan opened this issue Nov 10, 2024 · 3 comments · Fixed by #66889
Closed
4 of 6 tasks

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

carolinan opened this issue Nov 10, 2024 · 3 comments · Fixed by #66889
Labels
[Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond [Type] Bug An existing feature does not function as intended

Comments

@carolinan
Copy link
Contributor

carolinan commented Nov 10, 2024

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
@carolinan carolinan added [Type] Bug An existing feature does not function as intended [Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond labels Nov 10, 2024
@carolinan
Copy link
Contributor Author

Also reproduced on WordPress 6.6.2.

@getdave
Copy link
Contributor

getdave commented Nov 11, 2024

Thanks for reporting.

Confidence check @ndiego for 6.7.1 🙏

@github-project-automation github-project-automation bot moved this from 🐛 Punted to 6.7.1 to ✅ Done in WordPress 6.7 Editor Tasks Nov 11, 2024
@getdave getdave moved this from ✅ Done to 🐛 Punted to 6.7.1 in WordPress 6.7 Editor Tasks Nov 12, 2024
@getdave
Copy link
Contributor

getdave commented Nov 12, 2024

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
Labels
[Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond [Type] Bug An existing feature does not function as intended
Projects
Development

Successfully merging a pull request may close this issue.

2 participants