How to reproduce

- use a paragraph field on a content type with translation support and with the language widget enabled.
- go to the add content form
- change the language of the new content (let's say from English to German)
- click on the button to add a paragraph
The result should be that the paragraph form elements appear, but not the "Remove" and the Add other paragraph buttons, so basically you are stuck with those form elements. If you do not change the language in the workflow above, then it works.

The access to those buttons seems to be checked in src/Plugin/Field/FieldWidget/InlineParagraphWidget.php on line 299. As a temporary solution in our projects, we just used this:

$button_access = $paragraphs_entity->access('delete');

but most probably there has to be a better way of fixing the issue.

Comments

vasi1186 created an issue. See original summary.

miro_dietiker’s picture

Priority: Normal » Major

Nice catch. Indeed.

It means when i create a new node with a non-default source language, the paragraph widget does not allow adding more paragraphs.

vasi1186’s picture

Exactly, because the language of the paragraph entity is different than the language of the untranslated paragraph entity, but this should not be the case, because the untranslated paragraph entity should be the same as the original one in my opinion.

progzy’s picture

I have a similar problem when translating a node to another language ; no "remove" and "add" buttons.

I've then replaced the code for "$button_access" with the one above ("remove" button) + set "$add_more_access" ("add" button) to TRUE (line 735).

Is there any reasons that the code was designed this way? Is there any drawbacks (could it break something?) to show them as I did above?

miro_dietiker’s picture

@progzy that was discussed and buttons are hidden by design, also to avoid pitfalls.
If a translator would remove a paragraph, it would get removed for all languages!
If you translate, you should translate. A translation means having the same structure of information in a different language.
Alternatively you need this major feature implemented: #2461695: Support asymmetric translations

progzy’s picture

If a translator would remove a paragraph, it would get removed for all languages!

My field is declared as translatable and this is not the case ; I can remove paragraphs independently.

If you translate, you should translate. A translation means having the same structure of information in a different language.

Probably but if one adds a paragraph for source language "A" to an existing and already translated node it won't be reflected on language B and it won't be possible to add it since button is hidden.

miro_dietiker’s picture

@progzy We currently do NOT support translatable paragraph fields. See #2461695: Support asymmetric translations
That case is unrelated to this issue!

progzy’s picture

@miro_dietiker ok I think I understand now, thank you, my bad.

PS: However if I understand well I think a sentence from the "read me" is confusing. I've just created the following issue to clarify that point (and stop polluting this issue with none-related content) : https://www.drupal.org/node/2687839

johnchque’s picture

Assigned: Unassigned » johnchque
miro_dietiker’s picture

We should also investigate the situation where the source is changed for an existing entity and then an ajax action is triggered. I guess buttons now also disappear.

We need to find a much more reliable logic to detect when the user is translating.. and boost test coverage dedicated to the varying translation and / or source language change workflows.

johnchque’s picture

Status: Active » Needs review
StatusFileSize
new855 bytes

Added tests to prove this is not working as it should.

Status: Needs review » Needs work

The last submitted patch, 11: buttons_to_remove_and-2669732-11.patch, failed testing.

The last submitted patch, 11: buttons_to_remove_and-2669732-11.patch, failed testing.

The last submitted patch, 11: buttons_to_remove_and-2669732-11.patch, failed testing.

tduong’s picture

Status: Needs work » Needs review
StatusFileSize
new3.27 KB
new1.16 KB
new3.52 KB
new110.34 KB

Finally! After big discussion, attempts and final instructions from @miro_dietiker, we are able to make it work! :D

The last submitted patch, 15: buttons_to_remove_and-2669732-15-test_only.patch, failed testing.

The last submitted patch, 15: buttons_to_remove_and-2669732-15-test_only.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 15: buttons_to_remove_and-2669732-15.patch, failed testing.

The last submitted patch, 15: buttons_to_remove_and-2669732-15.patch, failed testing.

The last submitted patch, 15: buttons_to_remove_and-2669732-15.patch, failed testing.

The last submitted patch, 15: buttons_to_remove_and-2669732-15-test_only.patch, failed testing.

tduong’s picture

Status: Needs work » Needs review
StatusFileSize
new911 bytes
new1.16 KB
new3.64 KB

Missing additional check...

The last submitted patch, 22: buttons_to_remove_and-2669732-22-test_only.patch, failed testing.

The last submitted patch, 22: buttons_to_remove_and-2669732-22-test_only.patch, failed testing.

The last submitted patch, 22: buttons_to_remove_and-2669732-22-test_only.patch, failed testing.

tduong’s picture

Opened a "multilingual workflow bugs only meta issue" #2698239: Multilingual workflow bugs for a "general" discussion for these kind of bugs.

jfeltkamp’s picture

Status: Needs review » Reviewed & tested by the community

Patch works fine and code is ok as far as I can see.
Thank you for fixing this issue.

johnchque’s picture

@JFeltkamp please note that after debugging for long we realized that the last patch is not reliable, we are working on this with a colleague and we are uploading patches on the related issue #2698239: Multilingual workflow bugs. We can say after long discussions that the patches uploaded in the related issue contain the fix, we are adding tests now for covering every specific case.

miro_dietiker’s picture

Status: Reviewed & tested by the community » Postponed

Postponing for #2698239: Multilingual workflow bugs
The issue is likely to be solved there.
Currently we need to wait for an ERR release.

johnchque’s picture

Status: Postponed » Fixed

Fixed and test covered in #2698239: Multilingual workflow bugs

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.