-
Notifications
You must be signed in to change notification settings - Fork 798
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
Subscriptions Block: Invalidates when edited in different language #15776
Comments
I added |
cc @apeatling who's been working on some improvements to the Subscriptions block. |
I was doing some additional testing and it doesn't seem like you can modify the placeholder text through the block UI at all. |
Ah bummer, this was tested (#15107 (comment)) but somehow slipped still through. |
@sirreal Did you test this with the updates to the block in master? I couldn't reproduce this when I was working on it, but I probably wasn't doing it correctly. I'll try again today. |
@apeatling Yep, I just spun up a new site with Jetpack beta "Bleeding edge" build and was able to reproduce the issue following the instructions in the description. |
Couple of options I can think of:
|
I think |
Note that this affects several blocks (and maybe others--I only searched through the |
I'm not sure if it was the same reason, but the Map block and the Contact Info block were also broken (invalidated) with the translations for all the Mag 16, and I had to manually fix in the json files. It was really time-consuming, and the issue blocks us to deploy layouts regularly. |
Note, I updated my comment above to indicate that it's not an exhaustive list
|
In the case of the contact form and subscription blocks, the It could work for the other blocks that do not do this however. |
I tried this with the Calendly block, but I'm not having any luck with selecting via |
@lessbloat This might be a good candidate for the Manage Janitorial rotation |
@creativecoder by the looks of it, this is likely too complex for the Janitor rotation. |
I've just run a quick test, and of these only Subscriptions seems to be affected. The difference is that those blocks don't save the localized attributes in the block content, whereas Subscriptions does. Examples<!-- wp:jetpack/revue {"revueUsername":"test"} -->
<div class="wp-block-jetpack-revue">
<!-- wp:jetpack/button {"element":"button","text":"Subscribe"} /-->
<a class="wp-block-jetpack-revue__fallback" href="https://www.getrevue.co/profile/test">
https://www.getrevue.co/profile/test
</a>
</div>
<!-- /wp:jetpack/revue --> Revue has all the fields labels and placeholders as localized attributes, plus the button text, which is an attribute of the Button inner block. No field labels/placeholders are saved in the block content, as the form is built server-side. The inner Button doesn't break because the parent block is actually defining it with the localized attribute: in other words, we are actually setting its text attribute with the localized string. <!-- wp:jetpack/subscriptions -->
<div class="wp-block-jetpack-subscriptions wp-block-jetpack-subscriptions__supports-newline">
[jetpack_subscription_form
subscribe_placeholder="Enter your email address"
submit_button_text="Sign Up"
]</div>
<!-- /wp:jetpack/subscriptions --> Subscriptions (example trimmed for readability), instead, saves the defaults in the block content. I'm still trying to figure out a good solution, though. |
Actually I think I've found a nice solution! ✨ |
I've unassigned myself, but of course feel free to pick #16361 up! 🙂 |
If a Subscription Block is added to a post with one localization, then subsequently edited in another localization, the block will be invalidated with no good way of recovering. The default texts in the block must be maintained, customization of the texts will prevent invalidation.
Core Gutenberg is working out how to handle situations like this:
Some of the default block attributes are localized with
__
:jetpack/extensions/blocks/subscriptions/attributes.js
Lines 7 to 10 in db3e471
jetpack/extensions/blocks/subscriptions/attributes.js
Lines 19 to 22 in db3e471
These attributes are stored directly in the save function:
jetpack/extensions/blocks/subscriptions/save.js
Lines 24 to 47 in db3e471
jetpack/extensions/blocks/subscriptions/save.js
Lines 105 to 129 in db3e471
The block may be saved with a localized text
Enter your email address
, then when the editor loads and validates the block content, it finds an unexpected localization (e.g.Dirección de correo electrónico
) and determines that the block content is not valid.I wrote about the problem of "impure save" here in more detail: pafL3P-kL-p2
In this case, translations implicitly leak into the block's save, rendering them impure and susceptible to invalidation.
This causes the following issues:
This has been present since the very first iteration of the block: Automattic/wp-calypso#28887
cc: @obenland @iamtakashi
Steps to reproduce the issue
/wp-admin/admin.php?page=jetpack#/discussion
)/wp-admin/post-new.php
)/subscription
)/wp-admin/options-general.php
)/wp-admin/update-core.php
)Save (English):
Load (Spanish):
The text was updated successfully, but these errors were encountered: