-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Pattern: fix regression error in post type templates #55858
Pattern: fix regression error in post type templates #55858
Conversation
Patch tested: This is solving the issue with the "Uncaught TypeError: Cannot read properties of undefined (reading 'stylesheet')". Tested with both a parent theme, as well as with a child theme. ✅ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this! 🙇 Great catch!
I can confirm this PR fixes the issue. Without this PR and on 6.4, I see the following console errors with a post in a custom post type:
With this PR, the console errors disappear. I can also confirm that the optional chain operator is used in other places in the codebase, including after getCurrentTheme()
, so I'm confident this is a good fix. I think this is good to bring in and I've also labeled this for inclusion in 6.4.
I just cherry-picked this PR to the 6.4-gb-sync-11.5 branch to get it included in the next release: 0ac4d37 |
Awesome! Thank you @mikachan and @Rajinsharwar !! |
This update includes the following fixes reported after RC3: * Regression: [WordPress/gutenberg#55858 Fixes patterns not working anymore as a post template for custom post types]. Scenario: When creating a new post for any custom post type registered with its "template" argument set to a pattern. For this scenario, the pattern template no longer renders in the post editor or the frontend with 6.4, whereas it did render properly in 6.3.2. This package update resolves the console error raised: {{{ Uncaught TypeError: select(...).getCurrentTheme() is undefined }}} which restores the rendering of the pattern template. * Regression: [WordPress/gutenberg#55859 Fixes positioning and styles for the new lightbox's trigger] introduced in 6.4. Follow up to [57048], [57034], [56987], [56961], [56849], [56818], [56816]. Props renathoc, rajinsharwar, richtabor, joen, mikachan, hellofromTonya. Fixes #59411. git-svn-id: https://develop.svn.wordpress.org/trunk@57063 602fd350-edb4-49c9-b593-d223f7449a82
This update includes the following fixes reported after RC3: * Regression: [WordPress/gutenberg#55858 Fixes patterns not working anymore as a post template for custom post types]. Scenario: When creating a new post for any custom post type registered with its "template" argument set to a pattern. For this scenario, the pattern template no longer renders in the post editor or the frontend with 6.4, whereas it did render properly in 6.3.2. This package update resolves the console error raised: {{{ Uncaught TypeError: select(...).getCurrentTheme() is undefined }}} which restores the rendering of the pattern template. * Regression: [WordPress/gutenberg#55859 Fixes positioning and styles for the new lightbox's trigger] introduced in 6.4. Follow up to [57048], [57034], [56987], [56961], [56849], [56818], [56816]. Props renathoc, rajinsharwar, richtabor, joen, mikachan, hellofromTonya. Fixes #59411. Built from https://develop.svn.wordpress.org/trunk@57063 git-svn-id: https://core.svn.wordpress.org/trunk@56574 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This update includes the following fixes reported after RC3: * Regression: [WordPress/gutenberg#55858 Fixes patterns not working anymore as a post template for custom post types]. Scenario: When creating a new post for any custom post type registered with its "template" argument set to a pattern. For this scenario, the pattern template no longer renders in the post editor or the frontend with 6.4, whereas it did render properly in 6.3.2. This package update resolves the console error raised: {{{ Uncaught TypeError: select(...).getCurrentTheme() is undefined }}} which restores the rendering of the pattern template. * Regression: [WordPress/gutenberg#55859 Fixes positioning and styles for the new lightbox's trigger] introduced in 6.4. Follow up to [57048], [57034], [56987], [56961], [56849], [56818], [56816]. Props renathoc, rajinsharwar, richtabor, joen, mikachan, hellofromTonya. Fixes #59411. Built from https://develop.svn.wordpress.org/trunk@57063 git-svn-id: http://core.svn.wordpress.org/trunk@56574 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This update includes the following fixes reported after RC3: * Regression: [WordPress/gutenberg#55858 Fixes patterns not working anymore as a post template for custom post types]. Scenario: When creating a new post for any custom post type registered with its "template" argument set to a pattern. For this scenario, the pattern template no longer renders in the post editor or the frontend with 6.4, whereas it did render properly in 6.3.2. This package update resolves the console error raised: {{{ Uncaught TypeError: select(...).getCurrentTheme() is undefined }}} which restores the rendering of the pattern template. * Regression: [WordPress/gutenberg#55859 Fixes positioning and styles for the new lightbox's trigger] introduced in 6.4. Follow up to [57048], [57034], [56987], [56961], [56849], [56818], [56816]. Reviewed by jorbin. Merges [57063] to the 6.4 branch. Props renathoc, rajinsharwar, richtabor, joen, mikachan, hellofromTonya. Fixes #59411. git-svn-id: https://develop.svn.wordpress.org/branches/6.4@57064 602fd350-edb4-49c9-b593-d223f7449a82
This update includes the following fixes reported after RC3: * Regression: [WordPress/gutenberg#55858 Fixes patterns not working anymore as a post template for custom post types]. Scenario: When creating a new post for any custom post type registered with its "template" argument set to a pattern. For this scenario, the pattern template no longer renders in the post editor or the frontend with 6.4, whereas it did render properly in 6.3.2. This package update resolves the console error raised: {{{ Uncaught TypeError: select(...).getCurrentTheme() is undefined }}} which restores the rendering of the pattern template. * Regression: [WordPress/gutenberg#55859 Fixes positioning and styles for the new lightbox's trigger] introduced in 6.4. Follow up to [57048], [57034], [56987], [56961], [56849], [56818], [56816]. Reviewed by jorbin. Merges [57063] to the 6.4 branch. Props renathoc, rajinsharwar, richtabor, joen, mikachan, hellofromTonya. Fixes #59411. Built from https://develop.svn.wordpress.org/branches/6.4@57064 git-svn-id: http://core.svn.wordpress.org/branches/6.4@56575 1a063a9b-81f0-0310-95a4-ce76da25c4cd
What?
Fixes #55846
When loading the editor, the
getCurrentTheme()
is returningundefined
, which breaks the editor when the post type contains a pattern. So this PR fixes it.I'd appreciate it if it could be merged before WP 6.4 is released, otherwise, we'll have users facing this issue on their sites.
It seems it started to happen after this PR: #53423. cc @pbking, in case you have the opportunity to check it.
Why?
We have some post types in Sensei LMS which contains a template with patterns. It happens at least for the Course, Lesson and Email post types. This is one related issue: Automattic/sensei#7262 in Sensei repository.
Notice that it can happen with any post type that has a template with a pattern.
How?
I just added a optional chain operator to make sure it won't break when the current theme is not ready for use in the editor yet.
I didn't investigate deeper if it could have other related issues, but this small fix fixes the mentioned use case specifically.
Testing Instructions
Screenshots or screencast
The error before the fix: