Since Drupal 10.2, a new column for actions has been added in core's theme.inc template_preprocess_field_multiple_value_form.
This means the logic to disable the tabledrag if cardinality = 1 in paragraphs_preprocess_field_multiple_value_form needs to be adapted.

Here's the core commit
https://git.drupalcode.org/project/drupal/-/commit/be46dafb302ad16eeab76...

And the affected function in paragraphs.module (index is now 3, index 2 is the new actions column).
https://git.drupalcode.org/project/paragraphs/-/blob/8.x-1.17/paragraphs...

Issue fork paragraphs-3418303

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

HLopes created an issue. See original summary.

hlopes’s picture

Patch that removes both columns (action and order).

berdir’s picture

Status: Active » Needs review
nsavitsky’s picture

StatusFileSize
new54.44 KB
new57.67 KB

@hlopes Thank you very much for this patch and description, it helped me so much to understand what happened with paragraphs widget after 10.2 update.

So, if I understand correctly, in 10.2 we have "very special" new column for having actions. It looks like the problem is more complex than the case with cardinality = 1, because with 1.x paragraphs widget shows empty table cell (which actually breaks css/js) and shows actions in the content/title cell. I guess the correct approach will be to actually use this new cell, instead of hiding. That's why I extended the patch of @hlopes to implement this solution.

It works great with Claro.

Before patch:
before patch

After patch:
after patch

Unfortunately, it doesn't look good with Gin, because Gin shows paragraphs widget using "display:block" for table items and it has some magic css for calculating width and I don't really understand how it works (but it was broken before patch too, so it doesn't make it any worse :) ).

nsavitsky’s picture

I forgot to add patch itself. Here it goes.

Status: Needs review » Needs work

The last submitted patch, 5: 3418303-2-paragraphs__fix_sort_and_action_columns.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

nsavitsky’s picture

Ouch, this is painful. The moving actions to new column obviously crashed functional testing. I'll try to find some time to update tests if my fix makes sense.

recrit’s picture

the patch in #2 fixed the issue for me.

hudri’s picture

I've been testing a bit, the changes from #1038316 broke a lot of things in Paragraphs. I'm currently getting best results with patch from #2, in multi-lingual and nested scenarios. The patch from #5 has issues with nested paragraphs, in my case the < table >'s expanded horizontally far beyond the container < div >.

I still have a minor horizontal overlap, which is quite nasty on node edit forms, because the paragraph UI buttons now overlap from .layout-region-node-main into the sidebar .layout-region-node-secondary, which makes them unclickable with the mouse.

My quick and dirty hack for this was adding

.layout-region-node-main {
  z-index: 2;
}

to the admin theme

Does NOT solve the issue (might even make things worse with a huge sidebar, e.g. metatags module), but at least this workaround allows my editors to use the mouse again.

Bumping status to major due the inaccessability of the UI buttons.

hudri’s picture

hudri’s picture

Priority: Minor » Major
linhnm’s picture

Patch #2 work for me

budalokko’s picture

StatusFileSize
new25.15 KB
new26.7 KB

Patch in #2 works for me in Claro, but #5 still shows the "Collapse" button misplaced, leaving less space for the actual form fields:

Patch in #2:
Patch in 2

Patch in #5:
Patch in 5

berdir’s picture

Version: 8.x-1.17 » 8.x-1.x-dev
Priority: Major » Normal
Status: Needs work » Postponed (maintainer needs more info)
Issue tags: +Needs tests

I merged #3454273: Order select shows on a translation of a paragraphs field on 10.2+ which I think resolves this, my understanding from #5 is that there is still an issue with Gin, so keeping this open to verify and address that, without regressions on Claro which the patch there apparently has.

Extending tests would also be useful.

hanoii’s picture

I use Gin on most of my projects and #3454273: Order select shows on a translation of a paragraphs field on 10.2+ definitely sorted it out also on Gin.

nsavitsky’s picture

StatusFileSize
new107.94 KB

@berdir I just tested version 1.18 with Claro and it definitely looks better than it was before. Not ideal, unfortunately, because we still have issue with empty table cells (see screenshot below), but it doesn't catch your eye.

1.18 update

tame4tex’s picture

Status: Postponed (maintainer needs more info) » Needs work

As @nsavitsky confirmed this is not completely fixed.

template_preprocess_field_multiple_value_form() is automatically adding an extra table column for a form element item's '_actions'. \Drupal\Core\Field\WidgetBase::formMultipleElements() adds the '_actions' array key and populates it with the item's remove button.

Given \Drupal\paragraphs\Plugin\Field\FieldWidget\ParagraphsWidget::formMultipleElements() does not add '_actions' to its items, we end up with this extra empty column.

The question is should this be fixed in core or paragraphs? Should core automatically add a column for '_actions' without confirming that items do actually have that key?

tame4tex’s picture

Assigned: Unassigned » tame4tex

Added related issue

tame4tex’s picture

Assuming this wont be addressed in core, I have added a MR to fix the extra empty column issue.

I have refactored paragraphs_preprocess_field_multiple_value_form quite a bit in an attempt to improve readability and improve robustness.

I have manually tested on both paragraph widget types and all looks to be ok.

tame4tex’s picture

Status: Needs work » Needs review
er.garg.karan’s picture

I have updated to the latest version of paragraphs i.e. 1.18. I am using the Gin theme and this issue is fixed for me.

berdir’s picture

Status: Needs review » Needs work

phpstan correctly points out that there is an undefined $value variable.

tame4tex’s picture

Status: Needs work » Needs review

Undefined $value variable fixed. Back to NR.

davidiio’s picture

We successfuly applied this issue merge request plain diff as a patch on drupal 10.2.7 with paragraphs 1.19
Issue is fixed for us.
Thanks

tame4tex’s picture

There is a failing test on the MR \Drupal\Tests\paragraphs\FunctionalJavascript\ParagraphsStableEditPerspectivesUiTest::testEditPerspectives. But when I run the test locally it passes. The same test is also failing on the MR for #3529888: Entity form modes 'description' field can no longer be an empty string, so I believe it is an issue with the test and unrelated to this code change.

tame4tex’s picture

Assigned: tame4tex » Unassigned
berdir’s picture

Status: Needs review » Fixed
Issue tags: -Needs tests

Thanks, reproduced now and verified the fix, merging.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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