grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

[Bug] Drag and drop rendering improperly

Open 00salmon opened this issue 6 years ago • 10 comments

Version 0.14.40

  1. Click "Continue"
  2. Select "You have successfully signed up!" header (sqh-header)
  3. Drag sqh-header block between "Give $10 and Get $10" and text below
  4. sqh-header appears visually above the Give $10 Header, but below the Give $10 Header in the layer manager
  5. Drag sqh-header beneath "Rewards Dashboard" back inside "form-component"
  6. sqh-header appears visually above "Rewards Dashboard", but below in the layer section

Couldn't reproduce this bug with the demo, and I can't seem to figure out what the issue is. Tried multiple versions of grapesjs and the bug appears each time.

Tested on https://jsfiddle.net/00salmon/ocbxqm91/ using Chrome

00salmon avatar Nov 20 '18 17:11 00salmon

Seems like the issue is due to different empty "textnode"s you have in your JSON. How do you obtain that structure?

artf avatar Nov 20 '18 23:11 artf

Hey @artf,

Thanks for pointing that out. The JSON came from an internal example with more components and the missing bits must've been converted to empty textnodes.

I've removed the empty textnodes in the jsfiddle, but still seem to be getting the issue with the "sqh-header" landing in the wrong spot. Any other clues?

Cheers

00salmon avatar Nov 20 '18 23:11 00salmon

Please update the live demo with cleaned JSON

artf avatar Nov 21 '18 00:11 artf

the JSON should be proper now here: https://jsfiddle.net/00salmon/kpbx9st3/

00salmon avatar Nov 21 '18 00:11 00salmon

schermata 2018-11-21 alle 02 02 06 I think the issue happens because the number of DOM elements inside the sqh-global-container is not the same as its component models. Those last elements seems not to be inserted via the proper API

artf avatar Nov 21 '18 01:11 artf

Hey @artf,

I've removed those DOM elements from the container in case they were causing the issue but still seem to be getting the strange drag behavior. I updated the live demo to reflect that.

https://jsfiddle.net/00salmon/fs8gnpte/

As a note, the DOM is being generated via the use of <slot /> within <sqh-global-container>, and within <sqh-form-component> for the elements shown after the form completion. I tried removing those but the dragging still has the original problem.

00salmon avatar Nov 21 '18 18:11 00salmon

hey @artf thanks for responding so quickly to this one.

I work with @00salmon and we've been using Grapes with web components. I think that this bug is related to the interaction with the <slot/> elements required by web components and the canvas.

It's interesting that drag and drop via the side panels or by updating the Backbone models work correctly. The components are re-ordered and the canvas is updated correctly. Only drag and drop in the canvas itself seems to cause problems.

We'd be happy to provide more tests or a pull request, but we're really not sure where to start.

Let us know if there's anything else we can provide!

loganvolkers avatar Nov 22 '18 20:11 loganvolkers

Hi @loganvolkers thanks for your feedback. Probably you're right, something is conflicting with one of the web components specs. The module responsible for the d&d is Sorter and in case of the canvas it starts from startSort method Can you show me your integration with Web Components?

artf avatar Nov 23 '18 15:11 artf

That demo link is probably the best starting point.

Alternatively, we could put some more test scenarios together with a collection of Polymer and/or Stencil libraries, or even put together a super vanilla web component.

I should note that I think that GrapesJS + Web Components is an incredibly powerful combination that could change a lot about how people build web page templates. If you're not already using it for your new spin off project @artf I highly suggest you take a look ;)

loganvolkers avatar Dec 02 '18 07:12 loganvolkers

Here's a good example library to look at: BlazeUI

For example their timeline: https://www.blazeui.com/components/timelines

image

<blaze-timeline alternate loading>
  <blaze-timeline-item left>Nothing</blaze-timeline-item>
  <blaze-timeline-item type="brand">
    Big bang
    <p class="c-paragraph">
      Widely considered to be how the universe began
    </p>
  </blaze-timeline-item>
  <blaze-timeline-item type="info">Galaxies go everywhere</blaze-timeline-item>
  <blaze-timeline-item type="warning">Solar systems form</blaze-timeline-item>
  <blaze-timeline-item type="success">Earth appears</blaze-timeline-item>
  <blaze-timeline-item type="error">Human infestation occurs!</blaze-timeline-item>
  <blaze-timeline-item last>All this has happened before and will happen again</blaze-timeline-item>
  <blaze-timeline-item loading>Evolution</blaze-timeline-item>
</blaze-timeline>

And source code here: https://github.com/BlazeUI/blaze/blob/master/packages/atoms/src/components/timeline/blaze-timeline-item.tsx

And another demo link here: https://jsfiddle.net/ocbxqm91/128/

loganvolkers avatar Dec 02 '18 07:12 loganvolkers