-
Notifications
You must be signed in to change notification settings - Fork 198
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
Store controls in state #7706
base: trunk
Are you sure you want to change the base?
Store controls in state #7706
Conversation
Test the previous changes of this PR with WordPress Playground. |
WordPress Dependencies ReportThe
This comment was automatically generated by the |
Test the previous changes of this PR with WordPress Playground. |
); | ||
useEffect( () => { | ||
async function getMenuControls() { | ||
const response = await applyFiltersAsync( |
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.
Although this code works, I have no idea why or how. 😅 It looks good in theory, but when setting breakpoints or adding log statements in the code, I noticed that when the fetch
in Sensei Pro returns and setControls
is called below, the component does not re-render as expected. Despite this, the "Add to Group" and "Remove from Group" options are there in the UI. 🤯
Given I'm not clear on what is happening here, I'm somewhat averse to shipping this change.
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.
Maybe I'm missing something, but I didn't find where the applyFiltersAsync
comes from. Checking the Gutenberg package, it doesn't seem to be there.
I'm also seeing this error in my browser console: Uncaught (in promise) TypeError: (0 , _wordpress_hooks__WEBPACK_IMPORTED_MODULE_2__.applyFiltersAsync) is not a function
.
So I don't understand how the buttons are displayed for you. For me it's not being displayed. Maybe there is some other code adding them for you given a specific condition?
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.
It's in @wordpress/hooks
, so you'll need do reinstall npm
packages as I updated the version.
Updated the testing instructions.
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.
Even with that it's not finding the function for me. 🤔
Are you using a WP beta version?
The @wordpress/hooks
is not bundled in our scripts. It's imported directly from WP because of the dependency extraction plugin. I checked that the function was added 1 month ago, so we probably shouldn't use it.
BTW, the link I used in my previous comment was the Gutenberg repo in the Automattic organization instead of the WordPress organization. That's the reason it wasn't there. :P
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.
Are you using a WP beta version?
Oof, yes I am. I wasn't able to downgrade in the Beta Tester plugin so had to stay on 6.7. Back to square one then I guess. 😄 Thanks for taking a look!
Test the previous changes of this PR with WordPress Playground. |
Test the previous changes of this PR with WordPress Playground. |
As a copy of the state was originally passed to the function.
Test the previous changes of this PR with WordPress Playground. |
Test the previous changes of this PR with WordPress Playground. |
Test the previous changes of this PR with WordPress Playground. |
Related to https://github.com/Automattic/sensei-pro/issues/2620.
TODO:
Proposed Changes
Testing Instructions
npm install
.New/Updated Hooks
Deprecated Code
Pre-Merge Checklist