I'd like to be able to change the background color and make some other cosmetic changes to the active paragraph bundle. Could you consider adding an 'active' class to the TR element when the 'Edit' button is clicked and remove it when the 'Collapse' button is clicked?
Likewise, it would be helpful to have a 'delete' class added when the 'Remove' button is clicked. Maybe in this case it has both 'active' and 'delete' classes? Don't know about this.

| Comment | File | Size | Author |
|---|---|---|---|
| #23 | interdiff-2734303-18-23.txt | 3.83 KB | johnchque |
| #23 | add_class_to_tr_element-2734303-23.patch | 2.45 KB | johnchque |
| #18 | interdiff-2734303-15-18.txt | 1.27 KB | arpad.rozsa |
| #18 | add_class_to_tr_element-2734303-18.patch | 2.05 KB | arpad.rozsa |
| #16 | interdiff-2734303-14-15.txt | 792 bytes | arpad.rozsa |
Comments
Comment #2
capellicComment #3
capellicPlayed with this a bit this morning. Doesn't look like adding jQuery 'click' events to attach classes is going to work due to the TR classes getting updated when the edit form comes back via AJAX. So I thought that adding and #attributes parameter on the AJAX return paragraphs_edit_js() would work, but I don't see my test class in the document after the form is returned.
Comment #4
jonathanshawApparently the recent paragraphs sprint has produced quite a lot of activity around the question of how edit, preview and collapse are implemented. @miro_dietiker has said he will write it up and create some meta issues, so you might want to watch for that and postpone fixing for now.
Comment #5
miro_dietikerLet's first check in 8.x.
I think the edit / preview / closed / delete state should be indicated per row so you can address them in CSS.
But we don't have an active concept, such as all are collapsed except one.
If multiple are open, we would need to track focus to determine what element is active.
Also, we would need to support nesting similar to menus and indicate parents as active-parent or so.
That said, does core have this concept? If not, i think it's not our job to invent it. We first should open a core issue to discuss it, also with focus on the accessibility aspects.
Comment #6
capellicI'm in favor of this. Once a Paragraph field has several fields on it and the editor is scrolling up and down, it is easy to "lose where you are." Having some visual cue (e.g. green background color) would help the editor hone in where they left off.
Yes! This, too!
Comment #7
capellicI've managed to do a bit of UX improvement provided by the draggable table classes. For example:
Comment #8
miro_dietikerPlease always include a screenshot of an improvement, otherwise the proposals don't allow us to efficiently discuss the effect and you risk no one finds time to apply the patch and test everything to find the change you propose...
Comment #9
capellic@miro_dietiker, sorry about that. Since the changes involved interaction, I made a screencast.
https://dl.dropboxusercontent.com/u/4770698/Drupal-org/Paragraphs/node-2...
Comment #10
miro_dietikerThank you for the video. It's a nice alternative perspective on the Paragraphs experience. Will need to think a bit about it.
I don't understand yet though, what "active" means. In my understanding, only one item should be active and that would be the one with the last interaction.
What would you propose if i open / edit multiple paragraphs should be "active" in that case?
Comment #11
capellicRight, so we don't need "active" any longer as it is handled already, but an "edited" would be useful? I imagine that it would be good to be able to see which bundles have been changed?
Comment #12
miro_dietikerYeah a changed indicator indeed makes sense.
Comment #13
miro_dietikerThe issue scope here shifted with the discussion.
Meanwhile we have a change indicator (icon) in the new widget.
This issue should be limited to offering a class indicating the Paragraph type per row. This already allows easy CSS styling per Paragraph Type as a first step.
If something else is still a requirement, let's create dedicated follow-ups.
Comment #14
arpad.rozsa commentedComment #16
arpad.rozsa commentedFixed the part which makes the test fail.
Comment #17
miro_dietikerAnd now we want to check the class presence. :-)
Comment #18
arpad.rozsa commentedAdded the test to check if the class is present.
Comment #19
berdirWe're trying to avoid adding more test cases to the old WebTestBase based classes and instead write new test coverage when possible in BrowserTestBase tests.
None of the existing tests there seem like a good match, so maybe just start a new test class there for generic UI/Widget tests, maybe just do a second ParagraphsExperimentalUiTest in tests/src/Functional and then in a follow-up, we can convert the existing to a browser test as well.
Comment #20
johnchqueSwitching to Functional test. :)
Comment #21
johnchqueDo we need this if here? We are checking two lines below anyway.
Comment #22
miro_dietikerWe decided for paragraph-type--* .. After long religious BEM discussions, we stated that a specific type is considered a type modifier... and we don't consider it worth to repeat any of the parent block names to avoid overlength... ;-)
About the check: We first need to check if we are really inside a Paragraphs widget. We can not blindly loop over the table... Maybe check the key that is used for foreach?
Comment #23
johnchqueUpdating tests, class and adding back the condition I removed. It makes sense to have it if that's the reason. :)
Comment #25
miro_dietikerGreat, now we can start to play with it in CSS. :-)
Comment #27
cegri commentedI'm new to Paragraphs. I came across this issue when searching a way to add "closed" or "edit" classes, as @capellic had requested. However it seems the topic has drifted away. I'll drop my solution below for anyone interested.
I needed the "edit" class to highlight the section that is open. We use nested paragraphs. Even though all are set to "Autocollapse: All", the structure would be cleaner if we could change the border color of the open paragraph.
So I brute forced my way;
in
ParagraphsWidget.php, tofunction formElement, around line 511Couple of questions:
1) Is there a better, more drupal-friendly way to do this? e.g., with a hook in my custom module.
2) I tried adding the class in
paragraphs_preprocess_field_multiple_value_formsimilar to @arpad.rozsa'sa patch above, but could not get the item mode information there. Is it possible?ps. Sorry for the mess! I'm not a professional programmer. I go around copying and tweaking other's codes.
edit: This does not add the class to the TR element, but to a div a few steps below. It misses only the tabledrag cell, good enough for our use. But it would be nice to style the complete TR line.