-
Notifications
You must be signed in to change notification settings - Fork 810
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
Button Block: Add parent-child syncing mechanism #15931
Conversation
Caution: This PR has changes that must be merged to WordPress.com |
Thank you for the great PR description! When this PR is ready for review, please apply the E2E results is available here (for debugging purposes): https://jetpack-e2e-dashboard.herokuapp.com/pr-15931 Scheduled Jetpack release: June 2, 2020. |
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.
@Copons Works great!
Looking forward to using it.
r208889-wpcom |
Changes proposed in this Pull Request:
passthroughAttributes
attribute to the Button block, to map parent attribute values to child (Button) attributes.In some cases, we might want the Button block to use a parent attribute.
For example, the parent block might have a link that we want to use for the button as well.
Inner blocks templates don't update after mount, so we need another way to keep them in sync.
The
passthroughAttributes
is an object that indicates which parent attributes we want to sync to which child attributes.E.g.
{ childAttribute: 'parentAttribute' }
The
usePassthroughAttributes
hook retrieves the parent attributes values and sets them to the Button attributes, effectively keeping them in sync.See also: #15370 (comment)
Notes
For example, the
url
attribute is fine, but thetext
(used in the testing instructions below) not really.Example scenario
The Calendly block as a
url
attribute that stores a Calendly link, which is then used to either embed a Calendly widget, or as the href of a Button link.We can create the Button like this:
Does this pull request change what data or activity we track or use?
No
Testing instructions:
Since this block is not used anywhere yet, an easy test would be to manually update the Revue edit.js to fake a sync between the parent's
revueUsername
and the Button'stext
.Proposed changelog entry for your changes: