mirumee / legacy-views

A legacy fork of Saleor that contains the old storefront and dashboard code
Other
14 stars 14 forks source link

Image Order on Product Differs From Order in Edit Images Window #11

Open madranet opened 5 years ago

madranet commented 5 years ago

What I'm trying to achieve

Upload product images and put in certain order …

Steps to reproduce the problem

  1. Drag & Drop multiple images into product editor Edit Images window
  2. Note image order in Edit Images window
  3. View product in shop [Image order is different]

What I expected to happen

Image order in Editor should reflect image order on product page …

When I drag multiple images into the Edit Images window and then view the product in my shop, the images are not in the same order as they are displayed in the Edit Images window. I have to go back to the Edit Images window and rearrange the images by dragging them round –even if I end up putting them back in the same order they were originally– before the shop view will honour the order in the Edit Images window. Sometimes I have to do this a couple of times before the image order in the shop follows the image order in the Edit Images window.

Screenshots

1: Add new product and open 'Edit Images' screen:

2019-03-18_17-26-44

2: Drag in multiple images [note the order]:

2019-03-18_17-27-58

3: Preview product in shop [note image order is different]: 2019-03-18_17-28-47

4: Return to 'Edit Images' screen and drag images around to rearrange them –eventually putting them back into their original order: 2019-03-18_17-27-58

5: Now preview product again [Images are now in the correct order]:

2019-03-18_17-31-54

System information Operating system: OSX [test version running locally] Browser: Yandex.

maarcingebala commented 5 years ago

I can confirm that there is a bug - if you upload multiple images by drag & drop and immediately reorder them, in the web console you can see that an AJAX call to /reorder endpoint fails with error:

{"error": {"ordered_images": ["This field is required."]}}
jakubwi commented 5 years ago

@madranet Could you confirm that this is happening only if you reorder images (immediately after drag & drop upload) without refreshing product image gallery page?

I think the problem is in sortable.js. It is looking for sortable-items on page, but before refreshing (after drag & drop upload) there are none. https://github.com/mirumee/saleor/blob/a169db84b3fade10edf5c86564139adf4e3f252a/saleor/static/dashboard/js/components/sortable.js#L10

Before refreshing the items in image gallery have li class: col s12 m6 l4 product-gallery-item dz-preview dz-processing dz-image-preview dz-success dz-complete

and after refreshing: col s12 m6 l4 sortable-item