ClassicPress Galleries drag&drop not working

Before creating a new thread please be sure to check our support forum for other issues that may be similar.

If there are no other similar threads, please provide a general summary of the issue in the Title above.

Expected behavior

I should be able reorder this by drag&drop

Current behavior

Drag&drop not working

Possible solution

Maybe something was broken when you remove some library?

Steps to reproduce

  1. Fresh (or not) install of ClassicPress
  2. Chrome last version, Windows 10
  3. Open any post or page.
  4. Click “Add Media”
  5. Upload some images
  6. Click Create new gallery
  7. Try to reoder images as written: “Drag and drop to reorder media files.”
  8. Nothing heppened.

Context

I’m using galleries a lot. And needs custom order. Old library for this feature was laggie. Bun now I can’t use it at all.

I can confirm this. A quick and dirty solution for the moment is to go to ~wp-admin/widgets-form.php and find wp_enqueue_script( 'admin-widgets' ); at about line 26.

Then insert this line immediately above it:
wp_enqueue_script( 'jquery-ui-sortable' );

When I find the file that actually performs the drag and drop, we can work out a longer term solution.

1 Like

Can you tell me what library ClassicPress use for sortable? On the menus it looks amazing, much better, than Wordpress.

1 Like

Thanks! We use SortableJS. It’s at ~wp-includes/sortable.min.js

1 Like

OK, I’ve found the file that performs the sorting in the gallery widget. It is not, as I would have expected, in the JS for the gallery widget itself but is embedded in the ~wp-includes/js/media-views.js file.

It doesn’t make sense for us to edit that file now, and nor does it make sense to write some code to use SortableJS to replace it right now because I am hoping to work (from February onwards) on replacing all the JavaScript that the media widgets (image, audio, video, and gallery) use. Now that I know of this issue, I can incorporate SortableJS to work on the gallery widget then.

For now, I’ll open a PR to make the fix I gave above so that we can get the sorting working again with the next CP update, because I would expect that my work on the widgets won’t be ready in time for CP 2.4.0 (though I’d love it to be done in time for 2.5.0).

1 Like

Ok. As I see, you want to do this task yourself and know much more, than I do. So I will not intervene.

Thank you!

I would be delighted if someone else took on this task! But I am the one who’s re-written the media grid view, the Custom HTML widget, and half of the Text widget, and all the stuff with SortableJS, so I was just expecting that it would be me who’d do the rest of this work on the widgets.

So if you want to help, please do!

So I will need to rewrite my gallery interface:

Hopefully, it will not be too hard. Thanks for warning in advance.

I never worked with SortableJS or media grid. So, maybe I will try to do something different, but still useful for all.

You won’t need to re-write anything. ClassicPress uses semantic versioning, so when we release v. 2.4.0 or 2.5.0, there will be no breaking changes (other than unintended bugs, of course). So, if you’re using the built-in Gallery widget, it should still work the same. And there will be plenty of opportunity to test it all before we release it.

The only way you’d need to re-write anything is if you have written some custom code that uses the jQuery Sortable module and want to switch to SortableJS. But you won’t be forced to switch. As long as you explicitly call jquery-ui-sortable in your code, whatever you have written will still work. This is what I mean about CP not creating breaking changes. While core will no longer use that module, it will still be bundled with ClassicPress until at least version 3.0.0.

I’m rewriting wp.media.gallery in a little bit hacky way. Don’t trully understand how it’s work. Will update and see if my code still works :slight_smile:

1 Like

That’s fine. Any updates we make to CP shouldn’t affect that until we get to version 3.0.0 at the earliest.

We are working on replacing all of the backbone.js-based approach for media files (as we have done in the media grid view, for example), but that just means that (until v 3.0.0) we write new code and don’t use the old code. But the old code will still be there for you to make use of as you like.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.