-
Notifications
You must be signed in to change notification settings - Fork 137
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
Bug: Fixing null/undefined theme argument for the WordPressBlocksProvider #2013
base: canary
Are you sure you want to change the base?
Conversation
…PressBlocksProvider
|
📦 Next.js Bundle Analysis for @faustwp/getting-started-exampleThis analysis was generated by the Next.js Bundle Analysis action. 🤖 This PR introduced no changes to the JavaScript bundle! 🙌 |
@moonmeister Can you review this please and see if you can still replicate issue #1986 please |
@moonmeister I need to update this PR as some of the logic isn't correct |
@moonmeister This is ready for review. |
Can you explain why/how this fixes the issue? |
What PR should solve is the issue around not allowing null for the theme argument for the WordPressBlockProvider. FWIW I couldn't ever replicate the bug but this is what the PR should do
|
Thank you for help on debugging this issue. I have updated the PR. I have also updated details on how to replicate the issue and also how it appears theme might be a redundant argument. |
Tasks
Description
Fixed an issue with the theme argument for the WordPressBlockProvider to allow for null or undefined #1986
The condition to check if WordPressThemeContext is not needed as theme is an optional argument as per our docs - https://faustjs.org/reference/wordpressblocksprovider
e.g.
So setting the theme argument null, undefined or not at all should not result in an error.
How to replicate the issue
If you setup an Next.js app with Faust Blocks you should be able to replicate the error.
src/pages/_app.js
src/pages/index.js
src/wp-blocks/index.js
if you run
npm run dev
you will get the following error:The following PR fixes that issue.
Further Discussion
After debugging this issue with @moonmeister we also found that the theme argument appears to be redundant.
If you have a look at any of the blocks, it is only passed to the getStyles component which doesn't use the theme argument.
e.g.
https://github.com/wpengine/faustjs/blob/canary/packages/blocks/src/blocks/CoreParagraph.tsx
https://github.com/wpengine/faustjs/blob/canary/packages/blocks/src/utils/get-styles/getStyles.ts
https://github.com/wpengine/faustjs/blob/canary/packages/blocks/src/utils/get-styles/getTextStyles.ts#L10
There is a question on whether this is needed as none of the style components use this argument.
Related Issue(s):
#1986
Testing
As described above using a next.js app
Screenshots
Documentation Changes
Dependant PRs