Problem/Motivation

It seems that the Add above is setting some value as a reference that is not cleared after completing the adding.
Later using the regular add paragraph does not append anymore at the end, but at the previous delta location.

Proposed resolution

Reset the delta after clicking "Add above".

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sasanikolic created an issue. See original summary.

sasanikolic’s picture

Status: Active » Needs review
FileSize
754 bytes

I noticed that the delta is cleared correctly with js in Drupal.paragraphsAddModal.openDialog::close(), but it gets added again after the ajax is finished. This patch is a workaround to remove the delta on every $addParagraphButton click, which is bad, but is the only solution I could think of (except writing ugly ajax callback functions). Any other suggestions?

miro_dietiker’s picture

Status: Needs review » Needs work

What confuses me is that this problem came already up, so we even should have test coverage.
Maybe it only is triggered with specific extra modules and specific JS?
Otherwise those tests would / should fail.

And then we should simply make sure the delta is only set under the correct situations and not need to apply clean-up workarounds.
Let's make sure this is test covered.

johnchque’s picture

I thought there was code already for clearing that hidden field? Was it removed somewhere or it is not being applied anymore?

sasanikolic’s picture

There's some code in ParagraphsExperimentalAddWidgetTest that checks the delta, but it is only checking it when we close the modal (which works), not after ajax is executed. This test needs to be expanded. I'm looking into that.

sasanikolic’s picture

I think this solution would be better. Reverted the workaround.

sasanikolic’s picture

Berdir’s picture

Status: Needs review » Needs work
Berdir’s picture

Assigned: sasanikolic » Unassigned
Status: Needs work » Reviewed & tested by the community

Failed as expected. Fix is a bit strange, but it works, don't have a better idea and we have a test.

Berdir’s picture

Status: Reviewed & tested by the community » Fixed

  • Berdir committed 0c38b39 on 8.x-1.x authored by sasanikolic
    Issue #3052907 by sasanikolic, Berdir: Add paragraph adds on previous...

Status: Fixed » Closed (fixed)

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