Problem/Motivation

Additional slot row disappears after value change when used in nested paragraphs (paragraph in another paragraph type)

D10, admin theme Gin

Steps to reproduce

Create a paragraph structure like:

1. Component (paragraph type)
-- Some field set one (nested paragraph type)
-- -- Office hours
-- -- [other fields]
-- [other field sets

2. Click "Add time slot"

3. Change any (time) value in the new slot

4. The row will disappear (the value is still there, just visually removed)

Proposed resolution

Adjusted js file to account for script re-initiations due to paragaph changes

Remaining tasks

Test

Comments

max.valetov created an issue. See original summary.

johnv’s picture

Component: Code » Code - widget
Status: Needs review » Needs work
Related issues: +#3449164: Refactor the JavaScript for the widget to use the once library

I have some questions about your patch.
- the patch is not against latest version, with for example part of #3449164: Refactor the JavaScript for the widget to use the once library in it. That is not a problem however to evaluate your patch. But it does already introduce some more focussing.
- you have a problem in a specific paragraphs constellation. I presume you have no problem in a less complex layout? (there were some issues with paragraphs before)
- in the first 2 parts, I guess the addClass/removeClass is the part that truely fixes your problem?
- in the first 2 parts you change the UX: removing the cleared row and adding the 'Add' link of the previous row. I guess that is not part of your problem, but an additional feature? Indeed , current behaviour is more like 'clear', then 'remove'. But I feel removing the clicked-upon row is confusing.
- in the last 2 parts, why do you switch from 'id' to 'data-drupal-selector'? Is that best practice? If so, I can change it, but it gives no technical/functional improvement, does it?

Additionally, please check the introduction of once in #3449164-11: Refactor the JavaScript for the widget to use the once library, if it will not break your use case.
I need some confirmation on the proposed change there.

johnv’s picture

Version: 8.x-1.17 » 8.x-1.x-dev
StatusFileSize
new2.48 KB

Please find the remainder of your original patch, for the hide and once features.

johnv’s picture

Title: Additional slot row disappears after value change when used in nested paragraphs » Paragraphs & OH: Additional slot row disappears after value change when used in nested paragraphs
andreasderijcke’s picture

Title: Paragraphs & OH: Additional slot row disappears after value change when used in nested paragraphs » Nested form elements & OH: Additional slot row disappears after value change

This does occur in other nested situations too, when using field_group (for example) to put the field in:

- details element
- tabs
- ...

Tested on the last DEV commit at moment of writing.

Will try to update the patch (or have a colleague do it), as it doesn't apply on the last DEV commit.

johnv’s picture

Thanks @andreasderijcke.
Please note that I just released a new version.
Please also take into account the open ticket #3449164: Refactor the JavaScript for the widget to use the once library

andreasderijcke’s picture

Assigned: Unassigned » andreasderijcke
andreasderijcke’s picture

Assigned: andreasderijcke » Unassigned

Getting #3449164: Refactor the JavaScript for the widget to use the once library fixed first might make fixing this easier, if only to avoid a merge hell.

andreasderijcke’s picture

Status: Needs work » Needs review

#3449164: Refactor the JavaScript for the widget to use the once library fixes this problem as far as I could reproduce and test it.

@max.valetov Can you check if this is the case for you too?

johnv’s picture

Version: 8.x-1.x-dev » 8.x-1.19
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

johnv’s picture

Title: Nested form elements & OH: Additional slot row disappears after value change » Nested paragraph form elements & OH: Additional slot row disappears after value change
johnv’s picture

Title: Nested paragraph form elements & OH: Additional slot row disappears after value change » Paragraphs & OH: Additional slot row disappears after value change
andreasderijcke’s picture