Problem/Motivation

We have collapse / expand feature to select in the widget.

Community reported that the collapse functionality should somehow always be present:
#2650306: Always offer Collapse/Preview/Edit

But this still requires a submit / rebuild and is not enough yet for advanced UX like dynamic drag and drop collapsing.

Proposed resolution

Autocollapse on drag and drop.

Offer an action link to Collapse / Expand all. The action needs to be JS based without and ajax.
Fast response is critical.

For this we need to decide how to display a collapsed summary
This could be an option: #2433933: Paragraph summary formatter

Initially we could also just try to collapse everything except the first field per paragraph.

Remaining tasks

User interface changes

A new JS action link to Collapse / Expand everything.
It should also collapse nested fields.

Comments

miro_dietiker created an issue. See original summary.

jonathanshaw’s picture

I think an important concern is to avoid too big a draggable element, to minimize the need for scrolling. For a draggable list which might
a) have many items
b) have nesting (one day)
c) need to be worked with on mobile etc.
it would seem best to keep the height of each item very small: one or 2 lines of text or a small thumbnail if there's an image field.

The name of the paragraph type already provides quite a lot of information, combined with the first 5-10 words of text from the paragraph might be enough.

So either summary formatter or first field could work, provided they were trimmed enough.

One question is the extent to which you try to maintain a preview-like environment (e.g. by keeping multiple columns if multi-column layouts are being used, perhaps preferring shrinking elements over trimming them), vs creating a tree-like abstract environment.

miro_dietiker’s picture

Discussed today at the Paragraphs Future sprint.

Amazee has implemented this as an extra module:
https://github.com/AmazeeLabs/paragraphs_collapsible

We think this feature could make sense unconditionally.

Steps to move forward:
1) Provide a patch against paragraphs, unconditional, unchanged.
2) Check UI for all the paragraph modes (closed, preview) and also multiple field instances
3) Determine if we only exclude closed widget setting (no JS collapse) and otherwise release without any setting
4) Add widget setting if needed
5) Commit and make user provide feedback ;-)
6) More improvements in follow-ups
7) Connect follow-up about nesting, dragging across field #2658694: Move a nested Paragraph across fields and nesting
8) Bring up the topic at DDD

dasjo’s picture

hi,

attached is a patch that ports the current functionality that we have in paragraphs_collapsible into the paragraphs module.

by default, paragraphs will be closed

you can expand them individually using the "+" sign or all by once using the "expand all" link

initially, we also had a nice feature to collapse everything when starting to drag & expand afterwards, but this led to some issues on long form pages with screens & editors getting lost in vertical space. if you are interested in trying it out, you can take a look here:
https://github.com/AmazeeLabs/paragraphs_collapsible/commit/2efb64aa6b6b...

this is intended to be used with the edit mode mainly and definitely needs alignment with the already existing features that paragraphs has (closed, edit & preview modes)

dasjo’s picture

johnchque’s picture

There was a long discussion about the vertical lines since they are not part of core patterns, will they be added anyway?

miro_dietiker’s picture

A minimum amount of steps to get this in:
1) Follow CSS no-vertical-line pattern defined
2) Expand it by default
3) Only apply it if the default edit widget mode is used. (not in preview, collapsed/closed)

AND lots uf [manual] testing. :-)

jonathanshaw’s picture

Might not this approach (#7.2 and #7.3) create undesirable complexity for maintainers and users?

There'd be 3 different edit modes, each with a different logic and distinct code.
In "Closed" mode, paras are closed by default and you use the AJAX action "Edit" to expand and the AJAX action "Collapse" to close them.
In "Edit" mode, paras are open as forms by default, you can't preview them, and you use the + and - to expand and close them.
In "Preview" mode, paras are open to preview by default, you use the AJAX action "Edit" to open as form, the AJAX action "Collapse" to go back to preview, and you can't close them.

Maybe it's worth a little extra care at this point to make a simpler solution, by cutting out some of the current AJAX logic at the same time as adding the new frontend-only functionality?

How about this?
1) We keep the 3 choices in the configuration: Closed, Edit, Preview
2) But Closed just means Edit mode, but with everything closed initially on the frontend using CSS /js as @dasjo's patch does. In terms of AJAX and the backend, we only have 2 states/actions/codepaths (Edit & Preview).
3) + and - for expand/collapse are available in both preview and edit modes . (working in the frontend only exactly as they do in edit mode in @dasjo's patch)
4) The actions "Preview" or "Edit" are always available, and there is no "Collapse" (which is just how preview mode currently works, except that the action to preview after editing is perversely called "Collapse").

To do this would require:
A) tweaking dasjo's code to apply in preview mode also
B) Removing AJAX collapse
C) Simplifying the conditional logic about when to show Preview/Edit/Collapse actions

P.S. There's quite a few out-of-scope CSS tweaks in the patch, not just the vertical lines, and quite a few tweaks of uncertain purpose that may or may not be in scope.

miro_dietiker’s picture

Status: Active » Postponed

Sorry jonathanjfshaw, the Sprint discussions on thursday and friday covered this in deep depth, but the tickets haven't been updated yet.

We wanted to go for a JS approach, because it removes the ajaxy delays. Also, if we want to do autocollapsing on drag and drop, a server interaction roundtrip does not work.

However, Dasjo mentioned they removed autocollapsing on drag&drop anyway. It created issues with the scroll position.
A prerendered version creates confusion, since on JS collapse it would display outdated information!

That said, yes we want to improve the current existing closed, preview, edit modes and focus on the other existing issues, such as
#2650306: Always offer Collapse/Preview/Edit
Also, beside the per-item edit / collapse / open, we want to offer those actions through a drop down button to switch states on all items.

I will need some time to write down what we all discussed and create some meta issues with the arguments and future plans decided.

miro_dietiker’s picture

I created the main follow-up about the bulk edit / close / preview action:
#2738645: Add a collapse / edit all button