Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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".
Comments
Comment #2
sasanikolic CreditAttribution: sasanikolic commentedI 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?
Comment #3
miro_dietikerWhat 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.
Comment #4
johnchqueI thought there was code already for clearing that hidden field? Was it removed somewhere or it is not being applied anymore?
Comment #5
sasanikolic CreditAttribution: sasanikolic commentedThere'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.
Comment #6
sasanikolic CreditAttribution: sasanikolic commentedI think this solution would be better. Reverted the workaround.
Comment #7
sasanikolic CreditAttribution: sasanikolic commentedHere is the patch with the added test.
Comment #8
BerdirTest-only patch.
Comment #10
BerdirFailed as expected. Fix is a bit strange, but it works, don't have a better idea and we have a test.
Comment #11
Berdir