This PR can be summarized in the following changelog entry:
[schema-blocks] Fixes a bug where the schema block sidebar would not be correct after it had been added.
Relevant technical choices:
Used the useSelect WordPress React hook twice to make sure that the sidebar is re-rendered whenever:
The schemaBlocksValidationResults get updated.
The selected blockInstance gets updated.
Without them, the sidebar would only be re-rendered when another block was selected.
Test instructions
This PR can be tested by following these steps:
Create a new post.
Add a job posting block.
The job posting block should be selected.
Look at the sidebar of the selected job posting block.
The sidebar should show:
The schema analysis, with a red bullet indicating that not every required block is filled in.
A list of required blocks.
Containing an item for the Job title, Job description and Location block.
Each item should show an OK message, indicating that it occurs in the job posting block. (Note by @johannadevos: this OK will no longer be shown after https://yoast.atlassian.net/browse/P2-786 is fixed)
A list of recommended blocks.
Containing an item for the Job expiration date, Employment, Base salary, Requirements, Benefits and Apply button blocks.
Each item should show an OK message, indicating that it occurs in the job posting block. (Note by @johannadevos: this OK will no longer be shown after https://yoast.atlassian.net/browse/P2-786 is fixed)
Enter a job title, location and a job description.
When entering the last one, see that the sidebar shows a message indicating that all required blocks have been completed.
Enter a job title that is the same as the post title.
You should see an orange bullet in the sidebar analysis showing that the post title and job title are the same.
Remove a required block.
Note: it is a known bug that the warning block that is added does not have a sidebar.
Click on another block within the job posting.
The sidebar analysis should show two red bullets. One indicating the absence of the removed required block and one indicating that not all required blocks have been completed.
Re-instate the removed block by clicking on No, please undo this in the block removal warning.
The sidebar analysis should show a green bullet again indicating that all required blocks have been completed.
Added by @johannadevos:
If you have confirmed that the sidebar gets updated immediately after you have made changes to a block (and not only after selecting another block), close https://yoast.atlassian.net/browse/P2-780 and give it 0 points.
Impact check
This PR affects the following parts of the plugin, which may require extra testing:
The scheme blocks sidebar. Do a smoke/regression test to make sure that it still works as expected. But my guess is that the test instructions above cover most of the test cases.
Barring any known issues related to the sidebar.
UI changes
[ ] This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.
Quality assurance
[ ] I have tested this code to the best of my abilities
[ ] I have added unittests to verify the code works as intended
[x] When Adding the Job Posting block, it is selected and I immediately see an up-to-date sidebar with a red bullet in the analysis saying that not all required blocks have been completed.
[x] When I fill out all the required blocks, the analysis conclusion immediately becomes green.
[ ] When entering the same job and post title, I only see the orange bullet point after a publish and refresh, but that's due to this known bug: https://yoast.atlassian.net/browse/P2-832
[x] After the orange bullet point regarding the title has appeared, it is updated in real-time when I edit the job title.
[x] Removing and re-instating a required block works as expected.
Summary
This PR can be summarized in the following changelog entry:
Relevant technical choices:
useSelect
WordPress React hook twice to make sure that the sidebar is re-rendered whenever:schemaBlocksValidationResults
get updated.blockInstance
gets updated.Test instructions
This PR can be tested by following these steps:
OK
message, indicating that it occurs in the job posting block. (Note by @johannadevos: thisOK
will no longer be shown after https://yoast.atlassian.net/browse/P2-786 is fixed)OK
message, indicating that it occurs in the job posting block. (Note by @johannadevos: thisOK
will no longer be shown after https://yoast.atlassian.net/browse/P2-786 is fixed)Added by @johannadevos:
Impact check
UI changes
Quality assurance
Fixes #