-
Notifications
You must be signed in to change notification settings - Fork 894
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
Disables the AI buttons when the editor or blocks are in HTML mode #21443
Disables the AI buttons when the editor or blocks are in HTML mode #21443
Conversation
Pull Request Test Coverage Report for Build da23f6869e5c1d62822a62146fd4eeaccad4974aDetails
💛 - Coveralls |
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.
CR: 🏗️
A minor comment about maybe improving the performance of the solution.
Also, it would be nice if we had replication steps for the fix of the console error in the UI library, although not a blocker either.
@@ -31,6 +32,14 @@ const AIAssessmentFixesButton = ( { id, isPremium } ) => { | |||
const focusElementRef = useRef( null ); | |||
const [ buttonClass, setButtonClass ] = useState( "" ); | |||
|
|||
// Only enable the button when the editor is in visual mode and all blocks are in visual mode. | |||
const allVisual = useSelect( ( select ) => { |
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.
One thing that we can consider for the performance of determining if isEnabled
is maybe to
- first check the
editorMode
and return early if it's not onvisual
and only if it is to check all the blocks. - when checking all blocks, return early when we first see a block mode that's not
visual
so that we don't parse through all blocks and inner blocks every time.
But if we think that's a minor improvement and want to be pragmatic, I'm also ok with that 😅
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.
I like the first suggestion, I'll implement that 👍
But every
already returns early (see docs) so the second point is not an issue 😄
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.
Resolved by putting the check in a single useSelect
call, as also advised by https://developer.wordpress.org/news/2024/03/28/how-to-work-effectively-with-the-useselect-hook/#it-s-more-subtle-when-selecting-from-multiple-stores
Updated the test instructions, also added a small extra unit test, and slightly improved performance. Ready for a new round of CR 😸 |
Pull Request Test Coverage Report for Build 4911d3c9ba9e1f4ec5ee376d6e35844660cd1bc8Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
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.
CR + AT is ✅
Context
Summary
This PR can be summarized in the following changelog entry:
autoDismiss
prop on the Toast element and Notification component.Relevant technical choices:
getBlocks
from Gutenberg only retrieves the top-level blocks (see docs).Test instructions
Test instructions for the acceptance test before the PR gets merged
This PR can be acceptance tested by following these steps:
Finally, confirm that the (console) error
Invalid argument supplied to oneOfType. Expected an array of check functions, but received null at index 1.
that is shown without this PR in both the UI and the tests is no longer shown.Relevant test scenarios
Test instructions for QA when the code is in the RC
QA can test this PR by following these steps:
Impact check
This PR affects the following parts of the plugin, which may require extra testing:
UI changes
Other environments
[shopify-seo]
, added test instructions for Shopify and attached theShopify
label to this PR.Documentation
Quality assurance
Innovation
innovation
label.Fixes https://github.com/Yoast/plugins-automated-testing/issues/1594