-
Notifications
You must be signed in to change notification settings - Fork 818
Forms: Fix syncing of shared styles for nested fields and related undo issue #41708
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
Conversation
@@ -3,7 +3,7 @@ | |||
*/ | |||
import { useDispatch, useSelect } from '@wordpress/data'; | |||
import { useCallback, useEffect } from '@wordpress/element'; | |||
import { isEmpty, filter, first, map, pick, isNil } from 'lodash'; | |||
import { isEmpty, first, map, pick, isNil } from 'lodash'; |
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.
A good followup here would be to switch out the use of lodash functions for vanilla JS.
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Follow this PR Review Process:
Still unsure? Reach out in #jetpack-developers for guidance! |
Code Coverage SummaryCoverage changed in 1 file.
Full summary · PHP report · JS report Add label
I don't care about code coverage for this PR
|
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.
LGTM.
I spotted a bug with the code in trunk (see the review comment), but I think it can be handled separately from this PR. I'll leave it up to you.
NIH, but something else is the useSelect
will, I think, be pretty inefficient. It'll re-calculate siblings
constantly, even when the user is only hovering different blocks. It'd be better to calculate siblings
in the callback IMO.
projects/packages/forms/src/blocks/contact-form/util/with-shared-field-attributes.js
Outdated
Show resolved
Hide resolved
Appreciate the speedy review @talldan 👍
I've pushed a commit I think improves the situation regarding repeatedly collecting siblings but I'll need to give it a proper test and more thought tomorrow. I'm also not sure about the approach taken, so happy for further feedback to push it in the right direction. |
projects/packages/forms/src/blocks/contact-form/util/with-shared-field-attributes.js
Outdated
Show resolved
Hide resolved
I've updated this PR to not only fix the syncing of styles for the nested fields but also address some of the secondary issues noted in reviews and testing. These include:
The PR description and test instructions have been updated to reflect the latest state. Further enhancements or fixes should probably be done via follow-ups. To that end, I think this is ready for a final review before merging 🙏 |
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.
Tests well for me, and the code looks good. Thanks @aaronrobertshaw!
Fixes #41704
Proposed changes:
useSharedFieldAttributes
hook to factor in that form fields can be nested within other blocks and may not be immediate children of the primary form block.Other information:
Jetpack product discussion
N/A
Does this pull request change what data or activity we track or use?
No changes.
Testing instructions:
Test nested field style syncing:
Test undo functionality:
Test block insertion with synced styles:
Nested Field Syncing
Screen.Recording.2025-02-11.at.4.45.07.pm.mp4
Screen.Recording.2025-02-11.at.4.48.52.pm.mp4
Undo fix for general style sync
Screen.Recording.2025-02-12.at.4.22.18.pm.mp4
Screen.Recording.2025-02-12.at.4.24.06.pm.mp4
Source of truth and sync on mount fixes
Screen.Recording.2025-02-12.at.5.30.28.pm.mp4
Screen.Recording.2025-02-12.at.5.31.20.pm.mp4