may be related to #2919678: Collapse all button incorrectly shown and #2919685: Inconsistent behaviour for "Collapse all" and "Edit all" Buttons

Problem/Motivation

Given you use paragraphs experimental widget and configure it to use edit mode "Closed (same as in #2919678: Collapse all button incorrectly shown) and make sure to set Autocollapse to "None". Then create a new node with at least to paragraphs and save it. Now edit the node again.

As long as you do not click on the "Collapse all" button, paragraphs are not autocollapsed (as configured). But as soon as you click on "Collapse all", autocollapse will be activated and you can only have one paragraph open at a time

CommentFileSizeAuthor
#28 interdiff-2919689-25-28.txt1.29 KBjohnchque
#28 collapse_all_button-2919689-28.patch6 KBjohnchque
#28 collapse_all_button-2919689-28-test-only.patch2.18 KBjohnchque
#25 interdiff-2919689-23-25.txt3.85 KBjohnchque
#25 collapse_all_button-2919689-25.patch5.97 KBjohnchque
#25 collapse_all_button-2919689-25-test-only.patch2.15 KBjohnchque
#23 interdiff-2919689-20-23.txt2.48 KBjohnchque
#23 collapse_all_button-2919689-23.patch7.71 KBjohnchque
#23 collapse_all_button-2919689-23-test-only.patch3.87 KBjohnchque
#20 interdiff-2919689-14-20.txt4.52 KBjohnchque
#20 collapse_all_button-2919689-20.patch8.33 KBjohnchque
#20 collapse_all_button-2919689-20-test-only.patch4.49 KBjohnchque
#14 interdiff-2919689-11-14.txt3.53 KBjohnchque
#14 collapse_all_button-2919689-14.patch8.52 KBjohnchque
#14 collapse_all_button-2919689-14-test-only.patch5.41 KBjohnchque
#11 collapse_all_button-2919689-11.patch4.84 KBjohnchque
#11 collapse_all_button-2919689-11-test-only.patch2.48 KBjohnchque
#8 2919689_8.patch4.19 KBmtodor
#8 interdiff_2919689_8_6.txt447 bytesmtodor
#6 active_autocollapse_mode.png12.87 KBmtodor
#6 2919689_6.patch3.76 KBmtodor
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

daniel.bosen created an issue. See original summary.

daniel.bosen’s picture

Title: Collapse all button incorrectly shown » Collapse all button changes autocollapse behaviour
miro_dietiker’s picture

Yeah "Expand all" will disable the autocollapse again. This enable / disable of the autocollapse works in both directions.
It was designed for people who want this... ;-)

I guess we need an extra autocollapse setting that completely disables it - or create a new one that then triggers autocollapse behavior like now.

Autocollapse:

  • Never
  • Disabled until "collapse all"
  • All

Open for better labels. :-)

daniel.bosen’s picture

I think the current behaviour is confusing and not very obvious. Not sure about a good wording here. How many peaple want this anyway? :)
Maybe a second modifier could be introduced like this:

Autocollapse?
- yes
- no

Change autocollapse behaviour with Collapse all / Edit all?
- yes
- no

mtodor’s picture

Assigned: Unassigned » mtodor

I'll try to add this behavior proposed as it's proposed on #4, because with current behavior it's possible to start with "Autocollapse" enabled or disabled and it will change with "Collapse all" or "Edit all" action. So it's better to keep it separated instead of introducing 4th option to "Autocollapse" mode with: Enabled until "edit all".

And what do you think about using of Checkboxes instead of Dropdown buttons, since it's only true/false value in both cases?

mtodor’s picture

Assigned: mtodor » Unassigned
Status: Active » Needs review
FileSize
3.76 KB
12.87 KB

I have adjusted implementation a bit. Since there is one case where behaviour is not so nice - fe. when you have autocollapse: yes and change autocollapse on collapse/edit all: no - then "Edit all" button should not expand all paragraphs (in general, it should be disabled). So what I have changed is, that "Change autocollapse behaviour" option works only for "Collapse all" button and "Edit all" button will always disable Autocollapse.

Patch with a proposal is attached to issue.

Just one more proposal (not related to this issue). Since this autocollapse enable/disable on collapse/edit all is a bit understandable and hidden behaviour, maybe we could show indicator if autocollapse is enabled or disabled. For example:
Autocollapse Mode

Status: Needs review » Needs work

The last submitted patch, 6: 2919689_6.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

mtodor’s picture

Status: Needs work » Needs review
FileSize
447 bytes
4.19 KB

Corrected missing schema entry.

miro_dietiker’s picture

Status: Needs review » Needs work

OK, convinced and revoking #3 - Sorry for the change of direction. :-)
We don't want to have a new setting for this small extra.

+++ b/src/Plugin/Field/FieldWidget/ParagraphsWidget.php
@@ -2357,10 +2370,12 @@ class ParagraphsWidget extends WidgetBase {
-    elseif ($submit['button']['#paragraphs_mode'] === 'closed') {

This is a bug, it should consider the "Autocollapse" setting and only enable autocollapse if it is enabled in the widget setting.

At the same time, if it's easy, let's hide the Autocollapse setting completely with states when the default state is open.

More ideas about collapse UX in follow-ups and opt-in only.

johnchque’s picture

Assigned: Unassigned » johnchque

Working on this. :)

johnchque’s picture

OK, it seems that we didn't need to update the autocollapse setting at all.

Tests added. :)

The last submitted patch, 11: collapse_all_button-2919689-11-test-only.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Status: Needs review » Needs work

The last submitted patch, 11: collapse_all_button-2919689-11.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

johnchque’s picture

The last submitted patch, 14: collapse_all_button-2919689-14-test-only.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Status: Needs review » Needs work

The last submitted patch, 14: collapse_all_button-2919689-14.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

miro_dietiker’s picture

+++ b/src/Plugin/Field/FieldWidget/ParagraphsWidget.php
@@ -2365,14 +2372,6 @@ class ParagraphsWidget extends WidgetBase {
-    if ($submit['button']['#paragraphs_mode'] === 'edit') {
...
-    elseif ($submit['button']['#paragraphs_mode'] === 'closed') {

If you drop these, then expanding all is of a temporary effect if autocollapse is enabled in the widget.
It makes the autocollapse mode unusable for many cases.

If autocollapse is enabled in the widget settings, it is still needed to do these disable / enable switches.

johnchque’s picture

Then what should it be the desired behavior?
If autocollapse enabled:
- Edit first paragraph, second is closed
- Edit second paragraph, first is closed
- Edit all, all open (disabling autocollapse) until...
- Collapse all, all closed (autcollapse enabled) until "Editing all"
?

miro_dietiker’s picture

Exactly. You just put the widget state changes above into an if() that checks if the widget configuration has autocollapse enabled.

johnchque’s picture

The last submitted patch, 20: collapse_all_button-2919689-20-test-only.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Status: Needs review » Needs work

The last submitted patch, 20: collapse_all_button-2919689-20.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

johnchque’s picture

miro_dietiker’s picture

  1. +++ b/src/Plugin/Field/FieldWidget/ParagraphsWidget.php
    @@ -761,6 +768,7 @@ class ParagraphsWidget extends WidgetBase {
    +      $widget_state['autocollapse_default_setting'] = $this->getSetting('autocollapse');
    ...
    @@ -2417,12 +2425,13 @@ class ParagraphsWidget extends WidgetBase {
    

    Reads too much "setting" for me. :-) maybe just _default?

  2. +++ b/src/Tests/Experimental/ParagraphsExperimentalHeaderActionsTest.php
    @@ -119,6 +119,28 @@ class ParagraphsExperimentalHeaderActionsTest extends ParagraphsExperimentalTest
    +    $this->assertNoRaw('class="paragraphs-collapsed-description">Second text');
    

    I would prefer to assert here (additionally) the editable field...

    BTW below we have some nice helper checkParagraphInMode() but it's a BrowserTest... We should convert and reuse the helper in some mid term follow-up.

johnchque’s picture

The last submitted patch, 25: collapse_all_button-2919689-25-test-only.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Berdir’s picture

Status: Needs review » Needs work
  1. +++ b/tests/src/Functional/ParagraphsExperimentalWidgetButtonsTest.php
    @@ -100,19 +101,19 @@ class ParagraphsExperimentalWidgetButtonsTest extends BrowserTestBase {
    -    // Open the first paragraph and then the second. Opening the second closes
    -    // the first.
    +    // Open the first paragraph and then the second. Opening the second doesn
    +    // not close the first.
    

    typo: doesn not

  2. +++ b/tests/src/Functional/ParagraphsExperimentalWidgetButtonsTest.php
    @@ -100,19 +101,19 @@ class ParagraphsExperimentalWidgetButtonsTest extends BrowserTestBase {
     
         $this->getSession()->getPage()->findButton('field_paragraphs_1_edit')->press();
    -    $this->checkParagraphInMode('field_paragraphs_0', 'closed');
    +    $this->checkParagraphInMode('field_paragraphs_0', 'edit');
         $this->checkParagraphInMode('field_paragraphs_1', 'edit');
     
         // "Edit all" disables autocollapse.
    

    Ah, so we actually had explicit test coverage for the old behavior, interesting.

    The comment here needs an update I think, not correct anymore if autocollapse is not enabled in the first place in this context.

johnchque’s picture

Fixing comments as suggested above. :)

The last submitted patch, 28: collapse_all_button-2919689-28-test-only.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

miro_dietiker’s picture

Status: Needs review » Fixed

Yes, now it looks nice, committed.

Status: Fixed » Closed (fixed)

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