Problem/Motivation

While working on #2903543 and updating the Sortable.js library for drag&drop functionality, we noticed a strange behaviour in the case when the last paragraph is a "nested" one. When the window scroll position is at the very bottom and you try to move the last paragraph up, the moving paragraph gets stuck and loses focus.

Steps to reproduce:
- enable paragraphs_demo module
- apply patch from #2903543
- update the sortable.js library to the newest version (1.10.1 at the time of writing)
- create a new node with nested paragraphs
- scroll to the bottom of the page
- move the last nested paragraph 1px up

Proposed resolution

The sortable-drag class does not get removed when moving the last nested paragraph. Either find a way to remove it or recalculate the height of the paragraphs wrapper (the one around ALL paragraphs).

See the screenshot attached.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sasanikolic created an issue. See original summary.

sasanikolic’s picture

Here is the patch with a quickfix. We're setting the min-height when dragging the paragraph and removing it when the dragging is finished. This seems to fix the issue.

Note: I had to use .eq(0) to target the first element with that class, as the main wrapper of all paragraphs does not have a specific class. It would be helpful if it had that. Shall I do that here or is it too unrelated?

sasanikolic’s picture

Status: Active » Needs review
Berdir’s picture

I'm fine with adding a class here if that helps to make the JS simpler. Unless that's somehow complicated?

sasanikolic’s picture

I added the main wrapper around the paragraphs in this patch. I also realized the onStart event was not called in this particular case, so we use onChoose event instead and set the min height there.

Function name is unrelated, but I think there's a typo...

Berdir’s picture

Status: Needs review » Fixed

Discussed with Miro, the added class is quite complicated, he's OK with the eq(0), we just improved the comment a bit and committed.

  • Berdir committed dd0d13e on 8.x-1.x authored by sasanikolic
    Issue #3090023 by sasanikolic, Berdir, miro_dietiker: Last nested...

Status: Fixed » Closed (fixed)

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